pm

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

commit 974ebfe2ef64157720908a31dae3b1391826f269
parent e85aace532941b00cad1e8e5f1e090afa064cddb
Author: z3bra <willyatmailoodotorg>
Date:   Tue Dec 22 14:05:45 2015

Clean argument handling and usage()

Diffstat:
 pack.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/pack.c b/pack.c @@ -18,7 +18,7 @@ char *argv0; void usage(char *name) { - fprintf(stderr, "usage: %s [-hl] [-c <ARCHIVE> <FILE>[,FILES..]]\n", name); + fprintf(stderr, "usage: %s -cel <archive> [files..]\n", name); exit(1); } @@ -171,16 +171,17 @@ main (int argc, char **argv) const char *fn; ARGBEGIN{ - case 'l': - inspect(EARGF(usage(argv0))); - break; case 'c': - fn = EARGF(usage(argv0)); + if (argc <3) /* what a cute variable */ + usage(argv0); + fn = ARGF(); pack(fn, ++argv); break; case 'e': - fn = EARGF(usage(argv0)); - unpack(PACKAGE_ROOT, fn); + unpack(PACKAGE_ROOT, EARGF(usage(argv0))); + break; + case 'l': + inspect(EARGF(usage(argv0))); break; default: usage(argv0);