From 036bf7d2d1132664b13e17901ff693b5bcc9ef7d Mon Sep 17 00:00:00 2001 From: "Jonathan A. Sternberg" Date: Thu, 7 Jul 2016 16:54:24 -0500 Subject: [PATCH] Allow any variant of the help option to trigger the help --- CHANGELOG.md | 1 + cmd/influxd/help/help.go | 1 + cmd/influxd/main.go | 19 +++++++++---------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 879c332a50..1a7db921f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ With this release the systemd configuration files for InfluxDB will use the syst - [#6900](https://github.com/influxdata/influxdb/pull/6900): Trim BOM from Windows Notepad-saved config files. - [#6938](https://github.com/influxdata/influxdb/issues/6938): Added favicon - [#6507](https://github.com/influxdata/influxdb/issues/6507): Refactor monitor service to avoid expvar and write monitor statistics on a truncated time interval. +- [#6805](https://github.com/influxdata/influxdb/issues/6805): Allow any variant of the help option to trigger the help. ### Bugfixes diff --git a/cmd/influxd/help/help.go b/cmd/influxd/help/help.go index 88cb67e62d..c9bcc3849a 100644 --- a/cmd/influxd/help/help.go +++ b/cmd/influxd/help/help.go @@ -34,6 +34,7 @@ The commands are: backup downloads a snapshot of a data node and saves it to disk config display the default configuration + help display this help message restore uses a snapshot of a data node to rebuild a cluster run run node with existing configuration version displays the InfluxDB version diff --git a/cmd/influxd/main.go b/cmd/influxd/main.go index b89dbb0a3c..606f92909c 100644 --- a/cmd/influxd/main.go +++ b/cmd/influxd/main.go @@ -145,19 +145,18 @@ func (m *Main) Run(args ...string) error { func ParseCommandName(args []string) (string, []string) { // Retrieve command name as first argument. var name string - if len(args) > 0 && !strings.HasPrefix(args[0], "-") { - name = args[0] - } - - // Special case -h immediately following binary name - if len(args) > 0 && args[0] == "-h" { - name = "help" + if len(args) > 0 { + if !strings.HasPrefix(args[0], "-") { + name = args[0] + } else if args[0] == "-h" || args[0] == "-help" || args[0] == "--help" { + // Special case -h immediately following binary name + name = "help" + } } // If command is "help" and has an argument then rewrite args to use "-h". - if name == "help" && len(args) > 1 { - args[0], args[1] = args[1], "-h" - name = args[0] + if name == "help" && len(args) > 2 && !strings.HasPrefix(args[1], "-") { + return args[1], []string{"-h"} } // If a named command is specified then return it with its arguments.