/* * argsparse.c * * Copyright 2026 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * * */ #include #include #include "argsparse.h" size_t conf_size = 3; arg_property_t config[] = { "--hello", "-h/--help", "-o/--out=filename" }; int main(args_t argv, args_config_t config, args_config_size_t conf_size) { if (argv->ArgsGetSimpleSize()) { if (argv->ArgsGetSimpleNumbers()[0] == 0) { puts("Hello, world!"); } if (argv->ArgsGetSimpleNumbers()[0] == 1) { puts( "Options:" "\n" " " "--hello " " - " "print \"Hello, world!\"" "\n" " " "-h / --help" " - " "print this help" "\0" ); } return 0; } if (argv->ArgsGetNamesSize()) { if (argv->ArgsGetNamesNumbers()[0] == 2) { printf("Input: %s\n", argv->ArgsGetNamesVals()[0]); } return 0; } puts("Unknown option!"); return 1; }