coreos / bugs

Issue tracker for CoreOS Container Linux
https://coreos.com/os/eol/
147 stars 30 forks source link

Locksmith does not honor `--help` flag #1713

Open brianredbeard opened 7 years ago

brianredbeard commented 7 years ago

Issue Report

The CoreOS utility locksmith does not give helpful output upon giving the option --help. While it does provide this information as a verb instead of a posix style flag this is confusing for (at least one) user.

Bug

CoreOS Version

$ cat /etc/os-release 
NAME=CoreOS
ID=coreos
VERSION=1248.1.0
VERSION_ID=1248.1.0
BUILD_ID=2016-12-07-0251
PRETTY_NAME="CoreOS 1248.1.0 (MoreOS)"
ANSI_COLOR="1;32"
HOME_URL="https://coreos.com/"
BUG_REPORT_URL="https://github.com/coreos/bugs/issues"

Expected Behavior

$ locksmithctl --help
NAME:
    locksmithctl - Manage the cluster wide reboot lock.

USAGE: 
    locksmithctl [global options] <command> [command options] [arguments...]

VERSION:
    0.4.1+git

COMMANDS:
    help            Show a list of commands or help for one command
    lock            Lock this machine or a given machine-id for reboot.
    reboot          Reboot honoring reboot locks.
    send-need-reboot    send a 'need reboot' signal over dbus.
    set-max         Set the maximum number of lock holders
    status          Get the status of the cluster wide reboot lock.
    unlock          Unlock this machine or a given machine-id for reboot.

GLOBAL OPTIONS:
    --debug=false                       Print out debug information to stderr.
    --endpoint=http://127.0.0.1:2379,http://127.0.0.1:4001  etcd endpoint for locksmith. Specify multiple times to use multiple endpoints.
    --etcd-cafile=                      etcd CA file authentication
    --etcd-certfile=                    etcd cert file authentication
    --etcd-keyfile=                     etcd key file authentication
    --etcd-password=                    password for secure etcd communication
    --etcd-username=                    username for secure etcd communication
    --group=                        locksmith group
    --version=false                     Print the version and exit.

Run "locksmithctl help <command>" for more details on a specific command.

Actual Behavior


$ locksmithctl --help 
Usage of locksmithctl:
  -debug
        Print out debug information to stderr.
  -endpoint value
        etcd endpoint for locksmith. Specify multiple times to use multiple endpoints.
  -etcd-cafile string
        etcd CA file authentication
  -etcd-certfile string
        etcd cert file authentication
  -etcd-keyfile string
        etcd key file authentication
  -etcd-password string
        password for secure etcd communication
  -etcd-username string
        username for secure etcd communication
  -group string
        locksmith group
  -version
        Print the version and exit.

Reproduction Steps

  1. Run as mentioned
vcaputo commented 7 years ago

FYI the long "--foo" style flag is a GNU extension to getopt, not posix.

While I agree the help subcommand is annoying, it's also annoying how Go programs in general violate this established practice in more ways than just sticking help in a subcommand. All the long flags listed above are presented with a single hyphen despite being long flags. In an otherwise GNU system, this is totally inconsistent.

This should really be fixed more generally to bring Go flags into alignment with GNU getopt from the UX side, good luck with that.