#include #include #include #include "pass_util.h" #include "util.h" void print_usage(void); int cat(const char *path); void print_usage(void) { printf("Usage: pass COMMAND\n\n" "Commands:\n" " init key-id/fingerprint\n" " Initialize new password storage\n" " ls [ pass-path ]\n" " List passwords\n" " rm pass-name\n" " Remove password\n" " add pass-name\n" " Add new password\n" " gen pass-name\n" " Generate new password\n" " cat pass-name\n" " Show encrypted password\n" " help\n" " Show this help\n"); } int cat(const char *path) { const char *s = NULL; s = pass_cat(path); if (s) fputs(s, stdout); return (s == NULL); } int main(int argc, char *argv[]) { int r = 0; if (!--argc) { print_usage(); exit(EXIT_FAILURE); } ++argv; if (!strcmp("help", *argv)) { print_usage(); } else if (!strcmp("init", *argv)) { if (!argv[1]) err_die(1, "invalid usage, try pass help"); r = pass_init(argv[1]); } else if (!strcmp("cat", *argv)) { if (!argv[1]) err_die(1, "invalid usage, try pass help"); r = cat(argv[1]); } return r; }