aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <vyanitskiy@sysmocom.de>2020-10-24 05:25:43 +0700
committerVadim Yanitskiy <vyanitskiy@sysmocom.de>2020-10-24 05:25:43 +0700
commit33a248724ebb1962d5a5cc12b54e86029ee26b22 (patch)
treee774c5e371b73d24a999aee164dac492d0c3a9a8
parentaa29e33cb56ecdb21678ef50175f94ea8f6b4ed8 (diff)
main: add --vty-ref-mode, use vty_dump_xml_ref_mode()
-rw-r--r--src/osmo-msc/msc_main.c45
1 files changed, 34 insertions, 11 deletions
diff --git a/src/osmo-msc/msc_main.c b/src/osmo-msc/msc_main.c
index 4f614dbd4..aefdcbfea 100644
--- a/src/osmo-msc/msc_main.c
+++ b/src/osmo-msc/msc_main.c
@@ -121,7 +121,7 @@ static void print_usage()
static void print_help()
{
- printf(" Some useful help...\n");
+ printf("Some useful options:\n");
printf(" -h --help This text.\n");
printf(" -d option --debug=DCC:DMM:DRR: Enable debugging.\n");
printf(" -D --daemonize Fork the process into a background daemon.\n");
@@ -132,7 +132,35 @@ static void print_help()
printf(" -V --version Print the version of OsmoMSC.\n");
printf(" -e --log-level number Set a global loglevel.\n");
printf(" -M --mncc-sock-path PATH Disable built-in MNCC handler and offer socket.\n");
- printf(" --vty-ref-xml Generate the VTY reference XML output and exit.\n");
+
+ printf("\nVTY reference generation:\n");
+ printf(" --vty-ref-mode MODE VTY reference generation mode (e.g. 'expert').\n");
+ printf(" --vty-ref-xml Generate the VTY reference XML output and exit.\n");
+}
+
+static void handle_long_options(const char *prog_name, const int long_option)
+{
+ static int vty_ref_mode = VTY_REF_GEN_MODE_DEFAULT;
+
+ switch (long_option) {
+ case 1:
+ vty_ref_mode = get_string_value(vty_ref_gen_mode_names, optarg);
+ if (vty_ref_mode < 0) {
+ fprintf(stderr, "%s: Unknown VTY reference generation "
+ "mode '%s'\n", prog_name, optarg);
+ exit(2);
+ }
+ break;
+ case 2:
+ fprintf(stderr, "Generating the VTY reference in mode '%s' (%s)\n",
+ get_value_string(vty_ref_gen_mode_names, vty_ref_mode),
+ get_value_string(vty_ref_gen_mode_desc, vty_ref_mode));
+ vty_dump_xml_ref_mode(stdout, (enum vty_ref_gen_mode) vty_ref_mode);
+ exit(0);
+ default:
+ fprintf(stderr, "%s: error parsing cmdline options\n", prog_name);
+ exit(2);
+ }
}
static void handle_options(int argc, char **argv)
@@ -152,7 +180,8 @@ static void handle_options(int argc, char **argv)
{"log-level", 1, 0, 'e'},
{"mncc-sock-path", 1, 0, 'M'},
{"no-dbcounter", 0, 0, 'C'}, /* deprecated */
- {"vty-ref-xml", 0, &long_option, 1},
+ {"vty-ref-mode", 1, &long_option, 1},
+ {"vty-ref-xml", 0, &long_option, 2},
{0, 0, 0, 0}
};
@@ -167,14 +196,8 @@ static void handle_options(int argc, char **argv)
print_help();
exit(0);
case 0:
- switch (long_option) {
- case 1:
- vty_dump_xml_ref(stdout);
- exit(0);
- default:
- fprintf(stderr, "error parsing cmdline options\n");
- exit(2);
- }
+ handle_long_options(argv[0], long_option);
+ break;
case 's':
log_set_use_color(osmo_stderr_target, 0);
break;