pm

barely a pack manager
git clone git://z3bra.org/pm
Log | Files | Refs | README | LICENSE

commit cf3db968258c30b55d3917616bb21df71acd40ed
parent 40a21ff7404aca7885609396c77a85216b3cf895
Author: z3bra <willyatmailoodotorg>
Date:   Tue Jan  5 01:00:52 2016

Handle multiple args for ACTION_INSTALL

Multiple tarballs can now be installed with pm -a, by simply
passing more arguments on the command line.

All arguments passed after the flags are treated as tarballs.

Diffstat:
 pm.c | 31 +++++++++----------------------
 1 file changed, 9 insertions(+), 22 deletions(-)

diff --git a/pm.c b/pm.c @@ -25,13 +25,11 @@ struct pack { /* possible actions */ enum { + ACTION_INVALID = -1, ACTION_INSTALL = 0, ACTION_DELETE = 1, ACTION_UPDATE = 2, ACTION_INSPECT = 3, - ACTION_LIST_DEPS = 4, - ACTION_LIST_REMOTE = 5, - ACTION_INVALID = 6 }; /* error codes */ @@ -565,12 +563,11 @@ main (int argc, char **argv) { char *n = NULL; struct pack *p = NULL; - uint8_t action = ACTION_INVALID; + uint8_t action = ACTION_INSPECT; ARGBEGIN{ case 'a': action = ACTION_INSTALL; - n = EARGF(usage(argv0)); break; case 'd': action = ACTION_DELETE; @@ -581,24 +578,18 @@ main (int argc, char **argv) if (argc > 1) n = ARGF(); break; - case 'h': default: - usage(argv0); - return 0; + action = ACTION_INVALID; }ARGEND; - if (n) - p = pack_load(n); - switch (action) { - case ACTION_INSTALL: - if (!p) - return ERR_PACKAGE_LOAD; - if (metadata(PACKAGE_DATA, p) != 0) - return ERR_METADATA; - if (unpack(PACKAGE_ROOT, p->path) != 0) - return ERR_UNPACK; + while(*argv) { + p = pack_load(*(argv++)); + metadata(PACKAGE_DATA, p); + unpack(PACKAGE_ROOT, p->path); + pack_unload(p); + } break; case ACTION_DELETE: @@ -613,14 +604,10 @@ main (int argc, char **argv) /* handle me, Octave */ case ACTION_UPDATE: - case ACTION_LIST_DEPS: - case ACTION_LIST_REMOTE: default: usage(argv0); return ERR_INVALID_ACTION; } - pack_unload(p); - return 0; }