| 40 | |
| 41 | |
| 42 | def parse_args(args): |
| 43 | parser = argparse.ArgumentParser( |
| 44 | usage="lesspass SITE [LOGIN] [MASTER_PASSWORD] [OPTIONS]", |
| 45 | description=description, |
| 46 | epilog=EXAMPLES + COPYRIGHT, |
| 47 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 48 | ) |
| 49 | parser.add_argument( |
| 50 | "-v", "--version", action="version", version=version.__version__ |
| 51 | ) |
| 52 | parser.add_argument( |
| 53 | "site", nargs="?", help="site used in the password generation (required)" |
| 54 | ) |
| 55 | parser.add_argument( |
| 56 | "login", nargs="?", help="login used in the password generation. Default to ''." |
| 57 | ) |
| 58 | parser.add_argument( |
| 59 | "master_password", |
| 60 | default=os.environ.get("LESSPASS_MASTER_PASSWORD", None), |
| 61 | nargs="?", |
| 62 | help="master password used in password generation. Default to LESSPASS_MASTER_PASSWORD env variable or prompt.", |
| 63 | ) |
| 64 | parser.add_argument( |
| 65 | "-L", |
| 66 | "--length", |
| 67 | default=16, |
| 68 | choices=range(5, 35 + 1), |
| 69 | type=range_type, |
| 70 | help="password length (default: 16, min: 5, max: 35)", |
| 71 | metavar="[5-35]", |
| 72 | ) |
| 73 | parser.add_argument( |
| 74 | "-C", "--counter", default=1, type=int, help="password counter (default: 1)" |
| 75 | ) |
| 76 | parser.add_argument( |
| 77 | "-p", |
| 78 | "--prompt", |
| 79 | dest="prompt", |
| 80 | action="store_true", |
| 81 | help="prompt for values interactively", |
| 82 | ) |
| 83 | parser.add_argument( |
| 84 | "-c", |
| 85 | "--copy", |
| 86 | dest="clipboard", |
| 87 | action="store_true", |
| 88 | help="copy the password to clipboard", |
| 89 | ) |
| 90 | parser.add_argument( |
| 91 | "--exclude", |
| 92 | default=None, |
| 93 | help="exclude char from generated password", |
| 94 | ) |
| 95 | parser.add_argument( |
| 96 | "--no-fingerprint", |
| 97 | dest="no_fingerprint", |
| 98 | action="store_true", |
| 99 | help="hide visual fingerprint of the master password when you type", |