multimeric / ArgparsePrompt

Wrapper for the built-in Argparse, allowing missing command-line arguments to be filled in by the user via interactive prompts
GNU General Public License v3.0
11 stars 4 forks source link

Fwd from email: reading arguments from a file #9

Closed multimeric closed 3 years ago

multimeric commented 3 years ago

Your argparse-prompt is a step in the direction I want for argument processing my python code. But here is how I would like an argument processor to work.

  1. if "infile" or "config_file" etc, is one of the arguments, process the infile and collect all the values it sets.
  2. if any argument is set on the command line, it overrides what is set in the infile
  3. if any arguments are STILL missing, then set them - using argparse-prompt?

This is different from how argparse-prompt works now, since it does no check for what happened in the infile. I think i will need 3 slightly different calls to parse the args. first to check for infile, then to override with arguments on the command line, then once more for missing arguments that are needed.

multimeric commented 3 years ago

Hi, it looks like there are existing solutions for reading arguments from a file that should integrate fine with argparse and therefore ArgparsePrompt. I recommend looking into this answer here: https://stackoverflow.com/a/27434050/2148718. Let me know if this works.

In addition, unrelated to this library, click supports interactive prompts and also has a similar StackOverflow solution: https://stackoverflow.com/a/46391887/2148718. You might find this helpful as an alternative.