Feature: [Add support for -V option to give version](https://github.com/clicon/clixon/issues/472)
This commit is contained in:
parent
2f81a086c8
commit
261469be16
11 changed files with 209 additions and 42 deletions
|
|
@ -70,7 +70,7 @@
|
|||
#include "netconf_rpc.h"
|
||||
|
||||
/* Command line options to be passed to getopt(3) */
|
||||
#define NETCONF_OPTS "hD:f:E:l:C:q01ca:u:d:p:y:U:t:eo:"
|
||||
#define NETCONF_OPTS "hVD:f:E:l:C:q01ca:u:d:p:y:U:t:eo:"
|
||||
|
||||
#define NETCONF_LOGFILE "/tmp/clixon_netconf.log"
|
||||
|
||||
|
|
@ -637,6 +637,7 @@ usage(clicon_handle h,
|
|||
fprintf(stderr, "usage:%s\n"
|
||||
"where options are\n"
|
||||
"\t-h\t\tHelp\n"
|
||||
"\t-V \t\tPrint version and exit\n"
|
||||
"\t-D <level>\tDebug level\n"
|
||||
"\t-f <file>\tConfiguration file (mandatory)\n"
|
||||
"\t-E <dir> \tExtra configuration file directory\n"
|
||||
|
|
@ -683,6 +684,7 @@ main(int argc,
|
|||
size_t sz;
|
||||
int config_dump = 0;
|
||||
enum format_enum config_dump_format = FORMAT_XML;
|
||||
int print_version = 0;
|
||||
|
||||
/* Create handle */
|
||||
if ((h = clicon_handle_init()) == NULL)
|
||||
|
|
@ -702,6 +704,10 @@ main(int argc,
|
|||
case 'h' : /* help */
|
||||
usage(h, argv[0]);
|
||||
break;
|
||||
case 'V': /* version */
|
||||
cligen_output(stdout, "Clixon version %s\n", CLIXON_VERSION_STRING);
|
||||
print_version++; /* plugins may also print versions w ca-version callback */
|
||||
break;
|
||||
case 'D' : /* debug */
|
||||
if (sscanf(optarg, "%d", &dbg) != 1)
|
||||
usage(h, argv[0]);
|
||||
|
|
@ -743,12 +749,13 @@ main(int argc,
|
|||
while ((c = getopt(argc, argv, NETCONF_OPTS)) != -1)
|
||||
switch (c) {
|
||||
case 'h' : /* help */
|
||||
case 'V' : /* version */
|
||||
case 'D' : /* debug */
|
||||
case 'f': /* config file */
|
||||
case 'E': /* extra config dir */
|
||||
case 'l': /* log */
|
||||
case 'f' : /* config file */
|
||||
case 'E' : /* extra config dir */
|
||||
case 'l' : /* log */
|
||||
break; /* see above */
|
||||
case 'C': /* Explicitly dump configuration */
|
||||
case 'C' : /* Explicitly dump configuration */
|
||||
if ((config_dump_format = format_str2int(optarg)) == (enum format_enum)-1){
|
||||
fprintf(stderr, "Unrecognized dump format: %s(expected: xml|json|text)\n", argv[0]);
|
||||
usage(h, argv[0]);
|
||||
|
|
@ -855,7 +862,12 @@ main(int argc,
|
|||
if ((dir = clicon_netconf_dir(h)) != NULL &&
|
||||
clixon_plugins_load(h, CLIXON_PLUGIN_INIT, dir, NULL) < 0)
|
||||
goto done;
|
||||
|
||||
/* Print version, customized variant must wait for plugins to load */
|
||||
if (print_version){
|
||||
if (clixon_plugin_version_all(h, stdout) < 0)
|
||||
goto done;
|
||||
exit(0);
|
||||
}
|
||||
/* Load Yang modules
|
||||
* 1. Load a yang module as a specific absolute filename */
|
||||
if ((str = clicon_yang_main_file(h)) != NULL){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue