kjcolley7 / kjc_argparse Goto Github PK
View Code? Open in Web Editor NEWEasiest and cleanest argument parser in C
License: MIT License
Easiest and cleanest argument parser in C
License: MIT License
The main feature this library is currently missing is proper support for defining subcommands, such as docker login
or git pull
. These subcommands should be defined similarly to arguments, and they need to have a recursive argparse context with support for their own arguments and help.
It would be nice to automatically support the --help
argument without the programmer needing to manually declare an argument handler like:
ARG('h', "help", "Display this help message") {
ARGPARSE_HELP();
return 0;
}
The automatically defined one should register the long argument --help
, but probably not the small argument -h
. Perhaps it would also be good to keep the description set to NULL
so it doesn't appear in help output. There should be a configuration parameter to disable auto help.
The current "test suite" consists of running an example program a bunch of times from a shell script with different arguments and then diffing the output against a file. I'd prefer to have a better testing framework to do unit testing in a way that is hopefully much better and cleaner than diffing files.
Mainly considering using https://github.com/sheredom/utest.h.
Using the docker login
example, if I didn't set a custom usage string, docker login --help
would show the usage like this (assuming argv[0]
was docker
):
Usage: docker [-hpu] [OPTIONS] COMMAND ...
Right now, ARGPARSE_HELP()
has no way of knowing if it's being called from a subcommand.
There are a couple of approaches to solve this problem:
ARGPARSE_CONFIG_PROGNAME("docker login");
could be placed under ARG_COMMAND("login", "...") {
.Option 1 is nice because it requires substantially fewer core argparse changes.
Option 2 is better for automatically handling many subcommands, even deeply nested ones (like docker builder imagetools inspect
). It also has the benefit of producing the specific command prefix that was used to reach the argparse context. By that I mean in cases where there are multiple ways to invoke the same command (docker container ls
, docker container list
, docker container ps
, docker ps
).
When the --
argument is encountered, every subsequent argument should be passed to the ARG_POSITIONAL
handler. This should be an automatic, built-in behavior. There should also be a configuration parameter to disable this functionality if the program author doesn't want it. This should be an easy change.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.