From d5ca5d7feac6f51e5ef1a968eda7ca2896c11d95 Mon Sep 17 00:00:00 2001 From: Nathan Wagner Date: Sun, 25 Nov 2018 06:29:02 +0000 Subject: [PATCH] add option to echo note after creating --- zpm-install | 6 +++--- zpm-note.c | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/zpm-install b/zpm-install index c52f0a3..0d2055a 100755 --- a/zpm-install +++ b/zpm-install @@ -139,7 +139,7 @@ for pkgid in $pkglist; do fi else if zpm script -f $pkgfile -Fql -p pre-install $pkgid; then - zpm note -p $pkgid -m 'pre-install script not run' + zpm note -e -p $pkgid -m 'pre-install script not run' fi fi @@ -219,7 +219,7 @@ for pkgid in $pkglist; do zpm script -f $pkgfile -p post-install $pkgid $current else if zpm script -f $pkgfile -Fql -p post-install $pkgid; then - zpm note -p $pkgid -m 'post-install script not run' + zpm note -e -p $pkgid -m 'post-install script not run' fi fi @@ -235,7 +235,7 @@ for pkgid in $pkglist; do zpm script -f $pkgfile -p configure $pkgid else if zpm script -f $pkgfile -Fql -p configure $pkgid; then - zpm note -p $pkgid -m 'configure script not run' + zpm note -e -p $pkgid -m 'configure script not run' fi fi diff --git a/zpm-note.c b/zpm-note.c index 05ecda2..ced0d3f 100644 --- a/zpm-note.c +++ b/zpm-note.c @@ -12,11 +12,15 @@ void usage(void) { fprintf(stderr, "zpm-note [-I] [-s ...] [-S ] [package]\n"); } +void print_note(struct zpm_note *n) { + printf("%" PRId64 " %s %s\n", n->id, n->pkgid ? n->pkgid : "-", n->note); +} + int main(int ac, char **av){ int opt; struct zpm pkg; char *dbfile; - int fail; + int fail, echo = 0; int select = 1; @@ -38,6 +42,7 @@ int main(int ac, char **av){ * -H hash * -a all * -m note message, otherwise EDITOR/vi to edit a text file + * -e echo note after creating * zpm note -p pkgid -P path -H hash -m 'foo' * zpm note -l * zpm note -D @@ -53,6 +58,7 @@ int main(int ac, char **av){ case 'm': n.note = optarg; break; case 'n': n.id = strtoll(optarg, NULL, 10); break; case 'l': list = 1; break; + case 'e': echo = 1; break; case 'D': delete = 1; break; case 'A': ack = 1; break; case 'a': select = 3; break; @@ -75,15 +81,17 @@ int main(int ac, char **av){ if (zpm_open(&pkg, dbfile)) { if (list) { while (zpm_note(&pkg, &n, select)) { - printf("%" PRId64 " %s %s\n", n.id, - n.pkgid ? n.pkgid : "-", - n.note); + print_note(&n); zpm_note_free(&n); } } else if (n.note) { n.id = zpm_note_add(&pkg, n.pkgid, n.path, n.hash, "%s", n.note); if (n.id) { - printf("%" PRId64 "\n", n.id); + if (echo) { + print_note(&n); + } else { + printf("%" PRId64 "\n", n.id); + } } else { fprintf(stderr, "unable to create note\n"); pkg.error = 1; -- 2.40.0