From 9c2b26bf7f97338f409287de559c60e8aaed9e6c Mon Sep 17 00:00:00 2001 From: brent s Date: Fri, 3 Apr 2020 16:06:01 -0400 Subject: [PATCH] this is dumb. --- docs/README.adoc | 12 ++- vaultpass/args.py | 172 ++++++++++++++++++++++++++++++++++++++++- vaultpass/constants.py | 6 +- 3 files changed, 183 insertions(+), 7 deletions(-) diff --git a/docs/README.adoc b/docs/README.adoc index ef79878..a597e66 100644 --- a/docs/README.adoc +++ b/docs/README.adoc @@ -367,7 +367,7 @@ Per the Pass man page: If no COMMAND is specified, COMMAND defaults to either show or ls, depending on the type of specifier in ARGS. Alternatively, if PASSWORD_STORE_ENABLE_EXTENSIONS is set to "true", and the file .extensions/COMMAND.bash exists inside the password store and is executable, then it is sourced into the environment, passing any arguments and environment variables. Extensions existing in a system-wide directory, only installable by the administrator, are always enabled. .... -Due to this being Python, we lose some of this compatability. It may be possible to add this functionality in the +Due to this being Python, we lose some of this compatibility. It may be possible to add this functionality in the future, but it's lower priority currently. Similarly, we cannot set a default subcommand as of yet in Python via `argparse` (the library that VaultPass uses to @@ -440,7 +440,11 @@ Pass (and to a slightly lesser extent, Vault) relies almost entirely/exclusively configuration. VaultPass does not. ==== Workaround(s) -Relying entirely on environment variables for configuration is dumb, so I don't rely on that. All persistent +Relying entirely on environment variables for configuration is dumb, so I don't do on that. All persistent configuration can be either specified in the <> or can be overridden by -flags/switches to subcommands. **Some** configuration directives/behaviour may be overridden by environment variables, -but by and large this is not the case. +flags/switches to subcommands. **Some** configuration directives/behaviour may be overridden by environment variables +where supported by Vault/Pass upstream configuration. + + +== Submitting a Bug Report/Feature Request +Please use https://bugs.square-r00t.net/index.php?do=newtask&project=13[my bugtracker^]. diff --git a/vaultpass/args.py b/vaultpass/args.py index 7a71f2c..e14cbc7 100644 --- a/vaultpass/args.py +++ b/vaultpass/args.py @@ -88,7 +88,7 @@ def parseArgs(): dest = 'chars', default = constants.SELECTED_PASS_CHARS, help = ('The characters to use when generating a password (symbols included). ' - 'Default: {0}').format(constants.SELECTED_PASS_CHARS)) + 'Default: {0}').format(constants.SELECTED_PASS_CHARS.replace('%', '%%'))) gen.add_argument('-Cn', '--characters-no-symbols', dest = 'chars_plain', default = constants.SELECTED_PASS_NOSYMBOL_CHARS, @@ -113,7 +113,177 @@ def parseArgs(): gen.add_argument('length', type = int, default = constants.GENERATED_LENGTH, + nargs = '?', metavar = 'LENGTH', help = ('The length (number of characters) in the generated password. ' 'Default: {0}').format(constants.GENERATED_LENGTH)) + # GIT + git.add_argument('dummy_opts', + nargs = '+', + default = None, + metavar = 'dummy', + help = ('(Unused; kept for compatibility reasons)')) + # GREP + # I wish argparse supported arbitrary arguments. + # It *KIND* of does: https://stackoverflow.com/a/37367814/733214 but then I wouldn't be able to properly grab the + # regex pattern without more hackery. So here's to wasting my life. + ## DUMMY OPTIONS ## + #################################################################################################################### + grep.add_argument('-V', '--version', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-E', '--extended-regexp', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-F', '--fixed-strings', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-G', '--basic-regexp', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-P', '--perl-regexp', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-i', '--ignore_case', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('--no-ignore-case', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-v', '--invert-match', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-w', '--word-regexp', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-x', '--line-regexp', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-y', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-c', '--count', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-L', '--files-without-match', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-l', '--files-with-matches', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-o', '--only-matching', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-q', '--quiet', '--silent', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-s', '--no-messages', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-b', '--byte-offset', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-H', '--with-filename', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-n', '--line-number', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-T', '--initial-tab', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-u', '--unix-byte-offsets', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-Z', '--null', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-a', '--text', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-I', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-r', '--recursive', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-R', '--dereference-recursive', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('--line-buffered', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-U', '--binary', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-z', '--null-data', + action='store_true', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-e', '--regexp', + dest = 'dummy_0', + metavar = 'PATTERNS', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-f', '--file', + dest = 'dummy_1_0', + metavar = 'FILE', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('--exclude-from', + dest = 'dummy_1_1', + metavar = 'FILE', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-m', '--max-count', + dest = 'dummy_2_0', + metavar = 'NUM', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-A', '--after-context', + dest = 'dummy_2_1', + metavar = 'NUM', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-B', '--before-context', + dest = 'dummy_2_2', + metavar = 'NUM', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-C', '--context', + dest = 'dummy_2_3', + metavar = 'NUM', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('--label', + dest = 'dummy_3', + metavar = 'LABEL', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('--binary-files', + dest = 'dummy_4', + metavar = 'TYPE', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-D', '--devices', + dest = 'dummy_5_0', + metavar = 'ACTION', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('-d', '--directories', + dest = 'dummy_5_1', + metavar = 'ACTION', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('--exclude', + dest = 'dummy_6_0', + metavar = 'GLOB', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('--exclude-dir', + dest = 'dummy_6_1', + metavar = 'GLOB', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('--include', + dest = 'dummy_6_2', + metavar = 'GLOB', + help = ('(Dummy option; kept for compatibility reasons)')) + grep.add_argument('--color', '--colour', + dest = 'dummy_7', + metavar = 'WHEN', + const = None, + nargs = '?', + help = ('(Dummy option; kept for compatibility reasons)')) + #################################################################################################################### + grep.add_argument('pattern', + metavar = 'REGEX_PATTERN', + help = ('Regex pattern to search passwords')) + return(args) diff --git a/vaultpass/constants.py b/vaultpass/constants.py index 33905c8..0bd0ac7 100644 --- a/vaultpass/constants.py +++ b/vaultpass/constants.py @@ -3,7 +3,9 @@ import string # These are static. VERSION = '0.0.1' -ALPHA_PASS_CHARS = string.ascii_letters +ALPHA_LOWER_PASS_CHARS = string.ascii_lowercase +ALPHA_UPPER_PASS_CHARS = string.ascii_uppercase +ALPHA_PASS_CHARS = ALPHA_LOWER_PASS_CHARS + ALPHA_UPPER_PASS_CHARS NUM_PASS_CHARS = string.digits ALPHANUM_PASS_CHARS = ALPHA_PASS_CHARS + NUM_PASS_CHARS SYMBOL_PASS_CHARS = string.punctuation @@ -13,7 +15,7 @@ CLIP_TIMEOUT = 45 SELECTED_PASS_CHARS = ALL_PASS_CHARS SELECTED_PASS_NOSYMBOL_CHARS = ALPHANUM_PASS_CHARS CLIPBOARD = 'clipboard' -GENERATED_LENGTH = 25 # I personally would prefer 32, but Pass compatability... +GENERATED_LENGTH = 25 # I personally would prefer 32, but Pass compatibility... EDITOR = 'vi' # vi is on ...every? single distro and UNIX/UNIX-like, to my knowledge. if not os.environ.get('NO_VAULTPASS_ENVS'):