args done
This commit is contained in:
parent
e221401e1c
commit
a3b370cc6e
3
pass.py
3
pass.py
@ -12,6 +12,9 @@ def main():
|
|||||||
if args.oper == 'help':
|
if args.oper == 'help':
|
||||||
rawargs.print_help()
|
rawargs.print_help()
|
||||||
return(None)
|
return(None)
|
||||||
|
if args.oper == 'version':
|
||||||
|
print('{0} {1}'.format(vaultpass.constants.NAME,
|
||||||
|
vaultpass.constants.VERSION))
|
||||||
import pprint
|
import pprint
|
||||||
pprint.pprint(vars(args))
|
pprint.pprint(vars(args))
|
||||||
return(None)
|
return(None)
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
import argparse
|
import argparse
|
||||||
|
import os
|
||||||
##
|
##
|
||||||
from . import constants
|
from . import constants
|
||||||
|
|
||||||
|
|
||||||
def parseArgs():
|
def parseArgs():
|
||||||
args = argparse.ArgumentParser(description = 'VaultPass - a Vault-backed Pass replacement',
|
args = argparse.ArgumentParser(description = 'VaultPass - a Vault-backed Pass replacement',
|
||||||
prog = 'VaultPass',
|
prog = constants.NAME,
|
||||||
epilog = ('This program has context-specific help. Try "... cp --help". '
|
epilog = ('This program has context-specific help. Try "... cp --help". '
|
||||||
'This help output is intentionally terse; see "man 1 vaultpass" and the '
|
'This help output is intentionally terse; see "man 1 vaultpass" and the '
|
||||||
'README for more complete information, configuration, and usage.'))
|
'README for more complete information, configuration, and usage.'))
|
||||||
args.add_argument('-V', '--version',
|
args.add_argument('-V', '--version',
|
||||||
action = 'version',
|
action = 'version',
|
||||||
version = '%(prog)s {0}'.format(constants.VERSION))
|
version = '{0} {1}'.format(constants.NAME, constants.VERSION))
|
||||||
args.add_argument('-c', '--config',
|
args.add_argument('-c', '--config',
|
||||||
default = '~/.config/vaultpass.xml',
|
default = '~/.config/vaultpass.xml',
|
||||||
help = ('The path to your configuration file. Default: ~/.config/vaultpass.xml'))
|
help = ('The path to your configuration file. Default: ~/.config/vaultpass.xml'))
|
||||||
@ -44,6 +45,7 @@ def parseArgs():
|
|||||||
grep = subparser.add_parser('grep',
|
grep = subparser.add_parser('grep',
|
||||||
description = ('Search secret content by regex'),
|
description = ('Search secret content by regex'),
|
||||||
help = ('Search secret content by regex'))
|
help = ('Search secret content by regex'))
|
||||||
|
# This just does the same as -h/--help.
|
||||||
helpme = subparser.add_parser('help',
|
helpme = subparser.add_parser('help',
|
||||||
description = ('Show this help and exit'),
|
description = ('Show this help and exit'),
|
||||||
help = ('Show this help and exit'))
|
help = ('Show this help and exit'))
|
||||||
@ -382,18 +384,55 @@ def parseArgs():
|
|||||||
metavar = 'LINE_NUMBER',
|
metavar = 'LINE_NUMBER',
|
||||||
dest = 'clip',
|
dest = 'clip',
|
||||||
help = ('If specified, copy line number LINE_NUMBER (Default: {0}) from the secret to the '
|
help = ('If specified, copy line number LINE_NUMBER (Default: {0}) from the secret to the '
|
||||||
'clipboard instead of printing it.').format(constants.SHOW_CLIP_LINENUM))
|
'clipboard instead of printing it. '
|
||||||
|
'Use 0 for LINE_NUMBER for the entire secret').format(constants.SHOW_CLIP_LINENUM))
|
||||||
show.add_argument('-q', '--qrcode',
|
show.add_argument('-q', '--qrcode',
|
||||||
nargs = '?',
|
nargs = '?',
|
||||||
type = int,
|
type = int,
|
||||||
metavar = 'LINE_NUMBER',
|
metavar = 'LINE_NUMBER',
|
||||||
default = constants.SHOW_CLIP_LINENUM,
|
default = constants.SHOW_CLIP_LINENUM,
|
||||||
help = ('If specified, do not print the secret at but instead '))
|
help = ('If specified, do not print the secret at line number LINE_NUMBER (Default: {0}) but '
|
||||||
|
'instead generate a QR code of it (either graphically or in-terminal depending on '
|
||||||
|
'environment). '
|
||||||
|
'Use 0 for LINE_NUMBER for the entire secret').format(constants.SHOW_CLIP_LINENUM))
|
||||||
show.add_argument('-s', '--seconds',
|
show.add_argument('-s', '--seconds',
|
||||||
dest = 'seconds',
|
dest = 'seconds',
|
||||||
type = int,
|
type = int,
|
||||||
default = constants.CLIP_TIMEOUT,
|
default = constants.CLIP_TIMEOUT,
|
||||||
help = ('If copying to the clipboard (see -c/--clip), clear the clipboard after this many '
|
help = ('If copying to the clipboard (see -c/--clip), clear the clipboard after this many '
|
||||||
'seconds. Default: {0}').format(constants.CLIP_TIMEOUT))
|
'seconds. Default: {0}').format(constants.CLIP_TIMEOUT))
|
||||||
|
show.add_argument('path',
|
||||||
|
metavar = 'PATH/TO/SECRET',
|
||||||
|
help = ('The path to the secret'))
|
||||||
|
# VERSION has no args.
|
||||||
|
# IMPORT
|
||||||
|
def_pass_dir = os.path.abspath(os.path.expanduser(os.environ.get('PASSWORD_STORE_DIR', '~/.password-store')))
|
||||||
|
def_gpg_dir = os.path.abspath(os.path.expanduser(constants.SELECTED_GPG_HOMEDIR))
|
||||||
|
importvault.add_argument('-d', '--directory',
|
||||||
|
default = def_pass_dir,
|
||||||
|
metavar = '/PATH/TO/PASSWORD_STORE/DIR',
|
||||||
|
dest = 'pass_dir',
|
||||||
|
help = ('The path to your Pass data directory. Default: {0}').format(def_pass_dir))
|
||||||
|
importvault.add_argument('-k', '--gpg-key-id',
|
||||||
|
metavar = 'KEY_ID',
|
||||||
|
dest = 'key_id',
|
||||||
|
default = constants.PASS_KEY,
|
||||||
|
help = ('The GPG key ID to use. Default: {0}. '
|
||||||
|
'(If None, the default is to first check /PATH/TO/PASSWORD_STORE/DIR/.gpg-id if '
|
||||||
|
'it exists, otherwise use the '
|
||||||
|
'first private key we find)').format(constants.PASS_KEY))
|
||||||
|
importvault.add_argument('-H', '--gpg-homedir',
|
||||||
|
default = def_gpg_dir,
|
||||||
|
dest = 'gpghome',
|
||||||
|
metavar = '/PATH/TO/GNUPG/HOMEDIR',
|
||||||
|
help = ('The GnuPG "homedir". Default: {0}').format(def_gpg_dir))
|
||||||
|
importvault.add_argument('-f', '--force',
|
||||||
|
dest = 'force',
|
||||||
|
action = 'store_true',
|
||||||
|
help = ('If specified, overwrite the destination in Vault.'))
|
||||||
|
importvault.add_argument('mount',
|
||||||
|
metavar = 'MOUNT_NAME',
|
||||||
|
help = 'The mount name in Vault to import into (Pass\' hierarchy will be recreated). '
|
||||||
|
'This mount MUST exist first and MUST be KV2 if auth is provided that does not '
|
||||||
|
'have CREATE access on /sys/mounts!')
|
||||||
return(args)
|
return(args)
|
||||||
|
@ -2,6 +2,7 @@ import os
|
|||||||
import string
|
import string
|
||||||
|
|
||||||
# These are static.
|
# These are static.
|
||||||
|
NAME = 'VaultPass'
|
||||||
VERSION = '0.0.1'
|
VERSION = '0.0.1'
|
||||||
ALPHA_LOWER_PASS_CHARS = string.ascii_lowercase
|
ALPHA_LOWER_PASS_CHARS = string.ascii_lowercase
|
||||||
ALPHA_UPPER_PASS_CHARS = string.ascii_uppercase
|
ALPHA_UPPER_PASS_CHARS = string.ascii_uppercase
|
||||||
@ -18,6 +19,9 @@ SELECTED_PASS_NOSYMBOL_CHARS = ALPHANUM_PASS_CHARS
|
|||||||
CLIPBOARD = 'clipboard'
|
CLIPBOARD = 'clipboard'
|
||||||
GENERATED_LENGTH = 25 # I personally would prefer 32, but Pass compatibility...
|
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.
|
EDITOR = 'vi' # vi is on ...every? single distro and UNIX/UNIX-like, to my knowledge.
|
||||||
|
PASS_KEY = None
|
||||||
|
GPG_HOMEDIR = '~/.gnupg'
|
||||||
|
SELECTED_GPG_HOMEDIR = GPG_HOMEDIR
|
||||||
|
|
||||||
if not os.environ.get('NO_VAULTPASS_ENVS'):
|
if not os.environ.get('NO_VAULTPASS_ENVS'):
|
||||||
# These are dynamically generated from the environment.
|
# These are dynamically generated from the environment.
|
||||||
@ -28,3 +32,5 @@ if not os.environ.get('NO_VAULTPASS_ENVS'):
|
|||||||
CLIPBOARD = os.environ.get('PASSWORD_STORE_X_SELECTION', CLIPBOARD)
|
CLIPBOARD = os.environ.get('PASSWORD_STORE_X_SELECTION', CLIPBOARD)
|
||||||
GENERATED_LENGTH = int(os.environ.get('PASSWORD_STORE_GENERATED_LENGTH', GENERATED_LENGTH))
|
GENERATED_LENGTH = int(os.environ.get('PASSWORD_STORE_GENERATED_LENGTH', GENERATED_LENGTH))
|
||||||
EDITOR = os.environ.get('EDITOR', EDITOR)
|
EDITOR = os.environ.get('EDITOR', EDITOR)
|
||||||
|
PASS_KEY = os.environ.get('PASSWORD_STORE_KEY', PASS_KEY)
|
||||||
|
SELECTED_GPG_HOMEDIR = os.environ.get('GNUPGHOME', GPG_HOMEDIR)
|
||||||
|
Reference in New Issue
Block a user