]> granicus.if.org Git - graphviz/commitdiff
implement '--version' as an alias for '-V'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 6 Jan 2023 06:01:00 +0000 (22:01 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 8 Jan 2023 01:56:50 +0000 (17:56 -0800)
Gitlab: #1618

CHANGELOG.md
lib/common/input.c
tests/test_regression.py

index 24a1b762cc38694f39c6013d0071038bc6d350d6..795e9e23bf88998a61cba107c38b7bf8c3abc4a2 100644 (file)
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ## [Unreleased (7.0.7)]
 
+### Added
+
+- The command line option `--version` has been added as an alias for `-V`. #1618
+
 ### Fixed
 
 - The Autotools build system no longer errors when attempting libANN discovery
index 1778a5eca959559ce190192e11c9846745aebafc..d1e7591df526337497c310416603d6f0613b1a94 100644 (file)
@@ -16,6 +16,7 @@
 #include <xdot/xdot.h>
 #include <cgraph/agxbuf.h>
 #include <cgraph/exit.h>
+#include <cgraph/startswith.h>
 #include <cgraph/strcasecmp.h>
 #include <stdbool.h>
 #include <stddef.h>
@@ -269,7 +270,14 @@ int dotneato_args_initialize(GVC_t * gvc, int argc, char **argv)
     nfiles = 0;
     agxbinit(&xb, SMALLBUF, buf);
     for (i = 1; i < argc; i++) {
-       if (argv[i] && argv[i][0] == '-') {
+       if (argv[i] &&
+           (startswith(argv[i], "-V") || strcmp(argv[i], "--version") == 0)) {
+           fprintf(stderr, "%s - %s version %s (%s)\n",
+                   gvc->common.cmdname, gvc->common.info[0],
+                   gvc->common.info[1], gvc->common.info[2]);
+           if (GvExitOnUsage) graphviz_exit(0);
+           return 1;
+       } else if (argv[i] && argv[i][0] == '-') {
            rest = &argv[i][2];
            switch (c = argv[i][1]) {
            case 'G':
@@ -349,13 +357,6 @@ int dotneato_args_initialize(GVC_t * gvc, int argc, char **argv)
            case 'P':
                P_graph = gvplugin_graph(gvc);
                break;
-           case 'V':
-               fprintf(stderr, "%s - %s version %s (%s)\n",
-                       gvc->common.cmdname, gvc->common.info[0], 
-                       gvc->common.info[1], gvc->common.info[2]);
-               if (GvExitOnUsage) graphviz_exit(0);
-               return (1);
-               break;
            case 'l':
                val = getFlagOpt(argc, argv, &i);
                if (!val) {
index c41b9dae536719d5ac844e384e19e4fb7ce57c74..d0da09a003d4b9584c02b6d7cd4d32abf3533f94 100644 (file)
@@ -601,9 +601,9 @@ def test_1594():
   assert "line 3:" in stderr, \
     "GVPR did not identify correct line of syntax error"
 
-@pytest.mark.parametrize("long,short", (("--help", "-?"),
+@pytest.mark.parametrize("long,short", (pytest.param("--help", "-?",
+                                        marks=pytest.mark.xfail(strict=True)),
                                         ("--version", "-V")))
-@pytest.mark.xfail(strict=True)
 def test_1618(long: str, short: str):
   """
   Graphviz should understand `--help` and `--version`