Skip to content
Snippets Groups Projects

Update to the command line argument passer and logger

Merged Gregory Ashton requested to merge fix-cli into master
All threads resolved!
  1. Switches off the help for the default argparse. This allows a child to be instantiated after.
  2. Adds a demo to the docstring of how to instantiate a child argparse
  3. Make the dependence of setup_logger on the initial command line arguments more explicit and remove a global reference.
  4. Add some comments

The effect this has on most users is that --help will no longer work - however the actual arguments themselves will (e.g. --clean). While this is a mild loss (in that it isn't so easy for people to find out what is available) it will allow people to write command-line interfaces, which is probably going to be more useful in the end.

There may be a way to have both (something like this https://stackoverflow.com/questions/45806664/python-argparse-override-help-from-parent). But, I'd prefer to keep things clean for now.

I've put this as a WIP as I have yet to test it with anything other than the example given. @colm.talbot , could you perhaps give it a trial with some of your command line interfaces and see if there is anything subtle? I'm a bit worries that something will get overwritten, or not be overwritten when we are expecting it to.

Edited by Gregory Ashton

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Just for interest, can you explain in a little more detail why the --help option needed to be removed?

  • So basically, if there is a --help when it calls parse arguments (which it does when tupak is imported), it then prints the help and exists, but the users argparser hasn't been parsed yet. The result is the user won't see any of their options (though it would still work). I decided it's better to hobble the simpler script than the end users script.

  • Colm Talbot resolved all discussions

    resolved all discussions

  • Gregory Ashton unmarked as a Work In Progress

    unmarked as a Work In Progress

  • Colm Talbot approved this merge request

    approved this merge request

  • Moritz Huebner approved this merge request

    approved this merge request

  • Moritz Huebner mentioned in commit d8e813c8

    mentioned in commit d8e813c8

  • Please register or sign in to reply
    Loading