supercop

Basic CLI for supercop
git clone git://git.finwo.net/app/supercop
Log | Files | Refs | README | LICENSE

version.c (1345B)


      1 #include <stdio.h>
      2 #include <stdlib.h>
      3 
      4 #include "cli/command.h"
      5 #include "cli/common.h"
      6 
      7 static int cmd_version(int argc, const char **argv) {
      8   (void)argc;
      9   (void)argv;
     10   print_version();
     11   return 0;
     12 }
     13 
     14 void __attribute__((constructor)) cmd_version_setup(void) {
     15   struct cmd_struct *cmd = calloc(1, sizeof(struct cmd_struct));
     16   if (!cmd) {
     17     fprintf(stderr, "Failed to allocate memory for version command\n");
     18     return;
     19   }
     20   cmd->next                         = commands;
     21   cmd->fn                           = cmd_version;
     22   static const char *version_names[] = {"version", NULL};
     23   cmd->name                         = version_names;
     24   cmd->display                      = "version";
     25   cmd->description                  = "Show version number and exit";
     26   cmd->help_text =
     27       "supercop version - Show version number and exit\n"
     28       "\n"
     29       "Usage:\n"
     30       "  supercop version\n"
     31       "\n"
     32       "Description:\n"
     33       "  Print the version of supercop 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       "  supercop version           # Show the version\n"
     40       "  supercop --version         # Same, as a global flag\n"
     41       "  supercop -V                # Same, short form\n";
     42   commands = cmd;
     43 }