Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up command line options #4

Closed
dgelessus opened this issue Sep 17, 2019 · 1 comment
Closed

Clean up command line options #4

dgelessus opened this issue Sep 17, 2019 · 1 comment

Comments

@dgelessus
Copy link
Owner

The command line options are a bit of a mess. The tool has two different operating modes: "read mode" if one or more resource filters are specified (or if --all is passed), and "list mode" otherwise. Some options only apply to one of the two modes, and setting them in the other mode does nothing. There are also --header-system and --header-application, which are more or less a separate third mode.

To improve this situation, options that are incompatible with the current mode should cause errors. This would likely need to be checked manually, because argparse's mutually exclusive argument groups can't be used to represent the mode switching behavior.

It might also be a good idea to allow (or require) specifying the mode using explicit options, e. g. rsrcfork --list foo.rsrc and rsrcfork --read foo.rsrc "'TEXT'". This would allow for more readable help messages (only options applicable to the specified mode would be shown) and would allow adding more modes in the future (for example if write support is implemented, see #1). This wouldn't be any easier to handle using argparse though.

Since either way argparse's native features are insufficient here, it may be worth switching to another more powerful argument parsing library, such as argh or click.

@dgelessus
Copy link
Owner Author

Implemented in 3be4d9c, which adds a new subcommand-based command-line interface and deprecates the old CLI syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant