From 2d9e42669bfcb76286c72a3a648a1572f11cb2a8 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Fri, 9 Jan 2026 00:20:21 +0100 Subject: [PATCH] Add command line support for the 'version [-s|-f]' command With this commit the mentioned ngspice command(s) are also available on the command line. See ngspice --help for more information. --- src/main.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index c547d5475..01702c1f2 100644 --- a/src/main.c +++ b/src/main.c @@ -755,6 +755,8 @@ show_help(void) " -t, --term=TERM set the terminal type\n" " -h, --help display this help and exit\n" " -v, --version output version information and exit\n" + " -f, --version-full output full version information\n" + " --version-small output small version information\n" "\n" "Report bugs to %s.\n", cp_program, Bug_Addr); } @@ -952,6 +954,8 @@ int main(int argc, char **argv) {"define", required_argument, NULL, 'D'}, {"help", no_argument, NULL, 'h'}, {"version", no_argument, NULL, 'v'}, + {"version-full", no_argument, NULL, 'f'}, + {"version-small", no_argument, NULL, 256}, {"batch", no_argument, NULL, 'b'}, {"autorun", no_argument, NULL, 'a'}, {"circuitfile", required_argument, NULL, 'c'}, @@ -969,7 +973,7 @@ int main(int argc, char **argv) int option_index = 0; - int c = getopt_long(argc, argv, "D:hvbac:ino:pqr:st:", + int c = getopt_long(argc, argv, "D:hvfbac:ino:pqr:st:", long_options, &option_index); if (c == -1) { @@ -1004,6 +1008,22 @@ int main(int argc, char **argv) sp_shutdown(EXIT_INFO); break; + case 'f': /* Full version info */ + { + wordlist wl = { "-f", NULL, NULL }; + com_version(&wl); + sp_shutdown(EXIT_INFO); + } + break; + + case 256: /* --version-small */ + { + wordlist wl = { "-s", NULL, NULL }; + com_version(&wl); + sp_shutdown(EXIT_INFO); + } + break; + case 'b': /* Batch mode */ { bool x_false = FALSE;