Comment by ucarion

6 years ago

Since you bring up Docker, this little behavior has always baffled me:

    $ docker image ls -h
    Flag shorthand -h has been deprecated, please use --help

But:

    $ docker image -h ls
    Flag shorthand -h has been deprecated, please use --help
    Flag shorthand -h has been deprecated, please use --help
    Flag shorthand -h has been deprecated, please use --help

What's up with that? I'm guessing cobra nonsense, because everyone ends up wrapping cobra's weird API differently...

I know you're talking about how it's repeated three times, but something else here really bothers me.

I understand if they're deprecating it because they plan to replace it with something else, but if they don't then I'll be pretty disappointed. From their docs, it looks like some of their other subcommands have shorthands which conflict with `-h'? Fine, I guess, but that just means when `-h' does work it'll shoot people in the foot with that other behavior.

Software that clearly knows what I want, but refuses to, annoys me so much. For example,

    $ python3
    Python 3.9.0 (default, Dec  2 2020, 10:34:08) 
    [Clang 12.0.0 (clang-1200.0.32.27)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> quit
    Use quit() or Ctrl-D (i.e. EOF) to exit

because they added `quit' as a top level variable with a `__str__' defined which returns that string. Do anything else! Make the `__str__' definition quit the program or something, test if it's being run at the top level in the CLI and quit, special case the CLI input so if only `quit' is entered, it quits. Heck, maybe just prefill the `quit()' on the next line so I just have to hit return. Do anything but instruct me to do what you should have done in the first place.

  • I don't agree. Fail fast fail hard or you deliberately lie and confuse your users.

    If I make a mistake - tell me. If you allow me to do it slightly wrong then suddenly in my universe there is no consistency between commands and that is way worse than being told what I did wrong.

  • I mean if you did that how would you access 'quit' if it is defined? It's a bit more complicated than it seems.

    Though I get your general point.

    • You just access it, it's just a normal variable.

          $ python3
          Python 3.8.6 (default, Nov 18 2020, 23:56:33)
          [GCC 9.3.0] on linux
          Type "help", "copyright", "credits" or "license" for more information.
          >>> quit
          Use quit() or Ctrl-D (i.e. EOF) to exit
          >>> q = quit
          >>> quit = "foo"
          >>> quit
          'foo'
          >>> quit()
          Traceback (most recent call last):
            File "<stdin>", line 1, in <module>
          TypeError: 'str' object is not callable
          >>> q()
          $

      2 replies →

He doesn't claim that docker cli is well designed, only that he worked on it. Docker cli is pretty bad indeed, tar tier. Its web docs are also an example of butchered web 2.0.

Looks like it wants you to type --help, not -h.

Still weird though, since -h is indeed a very very common shorthand used in many commands.