dep

Package manager for embedded C libraries
git clone git://git.finwo.net/app/dep
Log | Files | Refs | README | LICENSE

main.c (1329B)


      1 #include <stdio.h>
      2 #include <stdlib.h>
      3 
      4 #include "command/command.h"
      5 
      6 static int cmd_version(int argc, const char **argv) {
      7   (void)argc;
      8   (void)argv;
      9   printf("%s\n", DEP_VERSION);
     10   return 0;
     11 }
     12 
     13 void __attribute__((constructor)) cmd_version_setup(void) {
     14   struct cmd_struct *cmd = calloc(1, sizeof(struct cmd_struct));
     15   if (!cmd) {
     16     fprintf(stderr, "Failed to allocate memory for version command\n");
     17     return;
     18   }
     19   cmd->next                          = commands;
     20   cmd->fn                            = cmd_version;
     21   static const char *version_names[] = {"version", "v", NULL};
     22   cmd->name                          = version_names;
     23   cmd->display                       = "v(ersion)";
     24   cmd->description                   = "Show version information";
     25   cmd->help_text =
     26       "dep version - Show version information\n"
     27       "\n"
     28       "Usage:\n"
     29       "  dep version\n"
     30       "  dep v\n"
     31       "\n"
     32       "Description:\n"
     33       "  Print the version of dep and exit.\n"
     34       "\n"
     35       "  The global --version flag is dispatched to this command, so both\n"
     36       "  produce the exact same output.\n"
     37       "\n"
     38       "Examples:\n"
     39       "  dep version           # Show the version\n"
     40       "  dep --version         # Same, as a global flag\n"
     41       "  dep -V                # Same, short form\n";
     42   commands = cmd;
     43 }