murarth / gumdrop

Rust option parser with custom derive support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Disable print of env var names - env vars not being parsed

flukejones opened this issue · comments

Unsure what my issue is here, but it seems that environment variables are not being parsed for me.

It would also be nice to have an optional argument to pass to parse_args_default_or_exit and similar to disable the printing/parsing of environment variables.

If you're talking about named environment variables, i.e. std::env::var, gumdrop does not access or parse those at all. When the documentation refers to "arguments from the environment," it's referring to arguments passed to the process via the command line, i.e. std::env::args.

I must be misunderstanding something then. A usual arg list will look like:

-d --debug DEBUG   <helptext>

The DEBUG isn't an environment variable then?

No. That DEBUG is what gumdrop calls the "metavar." It's just for help display purposes. You can change it with the options attribute; e.g. #[options(metavar = "X")]. It shouldn't be empty or disabled, though. It's there to indicate to the user that the option requires an argument value.

GNU programs usually show this differently, as e.g. --debug=DEBUG, which is perhaps more clear about its purpose. However, that might also give users the impression that the = is required, which it is not (for gumdrop or most GNU programs). I don't know. I'm conflicted about whether it should be done that way.

Ah I see it now. Sorry, I didn't recognize it for what it was due to that difference:

      --author               with -l, print the author of each file
  -b, --escape               print C-style escapes for non-graphic characters
      --block-size=SIZE      with -l, scale sizes by SIZE when printing them;
                               e.g., '--block-size=M'; see SIZE format below
  -B, --ignore-backups       do not list implied entries ending with ~

I guess I'll need to adjust some of the meta to better suit