News for hackers. Stuff that matters.
Re:CLI Guidelines – A guide to help you write better command... by ucarion on Friday December 04, 2020 @01:35PM (#25305948)
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...
Re:CLI Guidelines – A guide to help you write better command... by whelming_wave on Friday December 04, 2020 @04:38PM (#25308440)
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.
Re:CLI Guidelines – A guide to help you write better command... by tjoff on Saturday December 05, 2020 @05:18AM (#25313321)
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.

Re:CLI Guidelines – A guide to help you write better command... by resonantjacket5 on Friday December 04, 2020 @04:56PM (#25308671)
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.

Re:CLI Guidelines – A guide to help you write better command... by cle on Friday December 04, 2020 @05:27PM (#25309117)
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()
    $
Re:CLI Guidelines – A guide to help you write better command... by colejohnson66 on Friday December 04, 2020 @07:37PM (#25310345)
Wait... So it’s possible to make it so you can’t use `quit()`? Just overwrite it without saving it?
Re:CLI Guidelines – A guide to help you write better command... by cle on Friday December 04, 2020 @07:58PM (#25310513)
Yes. You can still send an EOF to quit (ctrl+d), or do "raise SystemExit()" which is all quit() does anyway:

    >>> print(inspect.getsource(quit.__call__))
        def __call__(self, code=None):
            try:
                sys.stdin.close()
            except:
                pass
            raise SystemExit(code)
Re:CLI Guidelines – A guide to help you write better command... by GoblinSlayer on Tuesday December 08, 2020 @03:12AM (#25343056)
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.
Re:CLI Guidelines – A guide to help you write better command... by codetrotter on Friday December 04, 2020 @02:12PM (#25306383)
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.