swansonk14 / typed-argument-parser

Typed argument parser for Python
MIT License
497 stars 40 forks source link

Support pre-processing config files with shlex. #60

Closed sykloid closed 2 years ago

sykloid commented 2 years ago

I find it useful to have the ability to use some common shlex-isms in my config files, namely quoted strings and comments.

This patch adds that facility if the user passes parse_config_files_with_shlex to parse_args.

I'm happy to make any requested aesthetic changes (parameter names, etc.).

The current implemented approach is programmatically backwards-compatible.

martinjm97 commented 2 years ago

Hi @sykora,

Thank you for the awesome PR! Is there any reason that parse_config_files_with_shlex should be a flag rather than being enabled all of the time? It seems like a direct improvement rather than an alternative.

Best, Jesse and Kyle

sykloid commented 2 years ago

@martinjm97 I wouldn't mind making parse_config_files_with_shlex the default behavior and removing the flag, I certainly plan to have it turned on at all times. I just didn't want to presume so, since it would break (some rather odd cases of) backwards compatibility.

If you want, I can submit another MR removing the flag and making it the default behavior.

martinjm97 commented 2 years ago

@sykora,

What do you think about making the default behavior what is now parse_config_files_with_shlex and then having a skip_config_file_parse that turns off the shlex parsing?

This will mitigate the (I assume) rare issues with backwards compatibility, and improve the default to one that allows for commenting in configs.

Thanks again!