]> git.draconx.ca Git - upkg.git/commitdiff
upkg: Specify package files as options.
authorNick Bowler <nbowler@draconx.ca>
Thu, 10 Dec 2009 04:34:13 +0000 (23:34 -0500)
committerNick Bowler <nbowler@draconx.ca>
Sun, 31 Jan 2010 21:59:23 +0000 (16:59 -0500)
Now, one must run "upkg -f foo.u" where previously one would run "upkg
foo.u".  This new syntax allows multiple packages to be specified on the
command line for purposes of dependency resolution and (soon) extraction
of specific objects.

The package operated upon is the last one specified in this manner.

src/upkg.c

index f7ace2a7763fa21e4556b5d552bb4bc7f577937d..191444ecd58755f43b3fca74bebc1a534fd96ed1 100644 (file)
@@ -40,10 +40,11 @@ enum {
 int verbose = 0;
 
 static const char *progname = "upkg";
-static const char *sopts = "ixvVH";
+static const char *sopts = "ixvf:VH";
 static const struct option lopts[] = {
        { "info",     0, NULL, 'i' },
        { "export",   0, NULL, 'x' },
+       { "file",     1, NULL, 'f' },
        { "verbose",  0, NULL, 'v' },
        { "version",  0, NULL, 'V' },
        { "help",     0, NULL, 'H' },
@@ -63,7 +64,7 @@ There is NO WARRANTY, to the extent permitted by law."
 
 void print_usage(FILE *f)
 {
-       fprintf(f, "Usage: %s [options] package\n", progname);
+       fprintf(f, "Usage: %s [options]\n", progname);
 }
 
 void print_help(void)
@@ -288,14 +289,26 @@ int package_export(struct upkg *pkg)
 int main(int argc, char **argv)
 {
        GTypeModule *pkg;
-       const char *pkgname;
+       const char *pkgname = NULL;
        unsigned mode = MODE_INFO;
        int opt, rc = EXIT_FAILURE;
 
        if (argc > 0) progname = argv[0];
 
+       if (u_pkg_vfs_init() != 0)
+               return EXIT_FAILURE;
+       if (u_object_module_init() != 0)
+               return EXIT_FAILURE;
+
        while ((opt = getopt_long(argc, argv, sopts, lopts, NULL)) != -1) {
                switch (opt) {
+               case 'f':
+                       pkgname = u_pkg_vfs_add_local(NULL, optarg);
+                       if (!pkgname) {
+                               fprintf(stderr, "failed to add package `%s'.\n", optarg);
+                               return EXIT_FAILURE;
+                       }
+                       break;
                case 'i':
                        mode = MODE_INFO;
                        break;
@@ -317,19 +330,8 @@ int main(int argc, char **argv)
                }
        }
 
-       if (argv[optind] == NULL) {
-               print_usage(stderr);
-               return EXIT_FAILURE;
-       }
-
-       if (u_pkg_vfs_init() != 0)
-               return EXIT_FAILURE;
-       if (u_object_module_init() != 0)
-               return EXIT_FAILURE;
-
-       pkgname = u_pkg_vfs_add_local(NULL, argv[optind]);
        if (!pkgname) {
-               fprintf(stderr, "failed to add package `%s'.\n", argv[optind]);
+               print_usage(stderr);
                return EXIT_FAILURE;
        }