diff options
author | sinanmohd <sinan@sinanmohd.com> | 2024-04-09 22:35:22 +0530 |
---|---|---|
committer | sinanmohd <sinan@sinanmohd.com> | 2024-04-09 22:59:41 +0530 |
commit | 19aaede67999a051eb01f303818fea3f67018e9d (patch) | |
tree | 0fdd77a51bd2c6bcac888688a3af0a29b3b5f4ed | |
parent | 5a1bcb408180b4659dbb4aee4a1cac494e7e6cba (diff) |
npass: better mimic behaviour of the original pass
-rw-r--r-- | src/npass/npass.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/npass/npass.c b/src/npass/npass.c index 0b5f792..869b6eb 100644 --- a/src/npass/npass.c +++ b/src/npass/npass.c @@ -202,15 +202,12 @@ out_free_pass: int main(int argc, char *argv[]) { int r = 0; + pass_store_t store_type; - if (!--argc) { - print_usage(); - exit(EXIT_FAILURE); - } ++argv; - - - if (!strcmp("help", *argv)) { + if (!--argc) { + r = ls(NULL, 0, NULL); + } else if (!strcmp("help", *argv)) { print_usage(); } else if (!strcmp("init", *argv)) { if (argc != 2) @@ -243,7 +240,19 @@ int main(int argc, char *argv[]) r = gen(argc, argv); } else if (argc == 1){ - r = cat(*argv); + store_type = pass_store_type(*argv); + + switch (store_type) { + case PASS_STORE_DIR: + r = ls(*argv, 0, NULL); + break; + case PASS_STORE_ENC: + r = cat(*argv); + break; + default: + invalid_usage_err_ret(); + break; + } } else { invalid_usage_err_ret(); } |