From 19aaede67999a051eb01f303818fea3f67018e9d Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Tue, 9 Apr 2024 22:35:22 +0530 Subject: npass: better mimic behaviour of the original pass --- src/npass/npass.c | 25 +++++++++++++++++-------- 1 file 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(); } -- cgit v1.2.3