aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2022-08-21 16:13:02 +0300
committerJoursoir <chat@joursoir.net>2022-08-22 00:48:45 +0300
commit0689d7efa8b6e9f1377e7e62b7755dc4370a01c3 (patch)
tree7a0c72ed46af9e288ac497b35e2faa34e8aba4b2 /src
parent54f71b7a23365134d7e2981dbe9d161a05c68896 (diff)
downloadlock-password-0689d7efa8b6e9f1377e7e62b7755dc4370a01c3.tar.gz
lock-password-0689d7efa8b6e9f1377e7e62b7755dc4370a01c3.tar.bz2
lock-password-0689d7efa8b6e9f1377e7e62b7755dc4370a01c3.zip
exec-cmd: add macro to print usage options
Diffstat (limited to 'src')
-rw-r--r--src/exec-cmd.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/exec-cmd.c b/src/exec-cmd.c
index 55d3b21..63db087 100644
--- a/src/exec-cmd.c
+++ b/src/exec-cmd.c
@@ -34,13 +34,15 @@
#include "tree.h"
#include "output.h"
+#define print_options(msg) print_usage("%s", msg)
+
int cmd_init(int argc, char *argv[])
{
const char description[] = "init gpg-key\n";
int retval = 0, result;
char *gpg_key = argv[2];
if(gpg_key == NULL) {
- print_usage("%s", description);
+ print_options(description);
return 1;
}
@@ -77,14 +79,14 @@ int cmd_insert(int argc, char *argv[])
case 'f': { flag_force = 1; break; }
case 'c': { flag_copy = 1; break; }
default:
- print_usage("%s", description);
+ print_options(description);
return 1;
}
}
char *path = argv[optind];
if(path == NULL) {
- print_usage("%s", description);
+ print_options(description);
return 1;
}
@@ -164,7 +166,7 @@ int cmd_edit(int argc, char *argv[])
char *editor, *password;
char *path = argv[1];
if(!path) {
- print_usage("%s", description);
+ print_options(description);
return 1;
}
@@ -265,14 +267,14 @@ int cmd_generate(int argc, char *argv[])
case 'f': { flag_force = 1; break; }
case 'c': { flag_copy = 1; break; }
default:
- print_usage("%s", description);
+ print_options(description);
return 1;
}
}
char *path = argv[optind];
if(path == NULL) {
- print_usage("%s", description);
+ print_options(description);
return 1;
}
@@ -317,7 +319,7 @@ int cmd_remove(int argc, char *argv[])
int result;
char *path = argv[1];
if(!path) {
- print_usage("%s", description);
+ print_options(description);
return 1;
}
@@ -356,13 +358,13 @@ int cmd_move(int argc, char *argv[])
switch(result) {
case 'f': { flag_force = 1; break; }
default:
- print_usage("%s", description);
+ print_options(description);
return 1;
}
}
if(!argv[optind] || !argv[optind+1]) {
- print_usage("%s", description);
+ print_options(description);
return 1;
}
@@ -454,7 +456,7 @@ int cmd_showtree(int argc, char *argv[])
case 'c': { flag_copy = 1; break; }
case 'C': { flag_color = 0; break; }
default:
- print_usage("%s", description);
+ print_options(description);
return 1;
}
}