akamensky / argparse

Argparse for golang. Just because `flag` sucks
MIT License
611 stars 62 forks source link

Provide <META> fields and Author Information in usage string #94

Closed pythonhacker closed 2 years ago

pythonhacker commented 2 years ago

First of all thanks for the awesome work. I noticed a few discrepancies and usage issues which can make this package better.

  1. Python's argparse provides a metavar field which adds a description, a META field for the argument which is missing from this package. So say if a field is a filename then it would show up as,
  -x  --export      <filename> Export all entries to <filename>

I could not find a way to do that with this package.

  1. Author information - I want to add a copyright plus author email field in my help string which is not possible with this package as it has an exact idea of how a usage string should be like.

I liked your package enough to use it for my project, but since these were missing I have added this in my fork of the package. If these changes make sense feel free to engage me in this issue.

Usage string using default argparse.

$ ./varuh -h
usage: varuh [-h|--help] [-e|--encrypt] [-A|--add] [-p|--path] [-a|--list-all]
             [-s|--show] [-c|--copy] [-v|--version] [-I|--init "<value>"]
             [-d|--decrypt "<value>"] [-C|--clone "<value>"] [-R|--remove
             "<value>"] [-U|--use-db "<value>"] [-f|--find "<value>"]
             [-E|--edit "<value>"] [-l|--list-entry "<value>"] [-x|--export
             "<value>"] [-g|--genpass "<value>"]

             Password manager for the command line for Unix like operating
             systems

Arguments:

  -h  --help        Print help information
  -e  --encrypt     Encrypt the current database
  -A  --add         Add a new entry
  -p  --path        Show current database path
  -a  --list-all    List all entries in current database
  -s  --show        Show passwords when listing entries
  -c  --copy        Copy password to clipboard
  -v  --version     Show version information and exit
  -I  --init        Initialize a new database
  -d  --decrypt     Decrypt password database
  -C  --clone       Clone an entry with <id>
  -R  --remove      Remove an entry with <id>
  -U  --use-db      Set <path> as active database
  -f  --find        Search entries with <term>
  -E  --edit        Edit entry by <id>
  -l  --list-entry  List entry by <id>
  -x  --export      Export all entries to <filename>
  -g  --genpass     Generate password of given <length>

Usage string after my changes,

$ ./varuh -h
usage: varuh [-h|--help] [-I|--init "<value>"] [-d|--decrypt "<value>"]
             [-C|--clone "<value>"] [-R|--remove "<value>"] [-U|--use-db
             "<value>"] [-f|--find "<value>"] [-E|--edit "<value>"]
             [-l|--list-entry "<value>"] [-x|--export "<value>"] [-g|--genpass
             "<value>"] [-e|--encrypt] [-A|--add] [-p|--path] [-a|--list-all]
             [-s|--show] [-c|--copy] [-v|--version]

             Password manager for the command line for Unix like operating
             systems

Options:

  -h  --help                   Print help information
  -I  --init        <path>     Initialize a new database
  -d  --decrypt     <path>     Decrypt password database
  -C  --clone       <id>       Clone an entry with <id>
  -R  --remove      <id>       Remove an entry with <id>
  -U  --use-db      <path>     Set <path> as active database
  -f  --find        <term>     Search entries with <term>
  -E  --edit        <id>       Edit entry by <id>
  -l  --list-entry  <id>       List entry by <id>
  -x  --export      <filename> Export all entries to <filename>
  -g  --genpass     <length>   Generate password of given <length>
  -e  --encrypt                Encrypt the current database
  -A  --add                    Add a new entry
  -p  --path                   Show current database path
  -a  --list-all               List all entries in current database
  -s  --show                   Show passwords when listing entries
  -c  --copy                   Copy password to clipboard
  -v  --version                Show version information and exit

AUTHORS
    Copyright (C) 2021 Anand B Pillai <abpillai@gmail.com>
akamensky commented 2 years ago

This is out of scope for this package.

It doesn't need separate fields for that. You can either add that into description or there's an option to provide your help message as a string (without any generated help messages).

Also conventionally there's no "copyright/author" in help message. That goes into manpage or into "version".

pythonhacker commented 2 years ago

Ok, cool - Thanks for the feedback. I guess I will keep my own fork of the package then.