1. 14
  1.  

  2. 2

    No idea how I’ve never heard of this before. They have a pretty nice method for configuring the options for a CLI app, and nice implementations in a ton of languages. I had been looking for something better for building CLI apps in Python and Rust, and this does the job great.

    1. 2

      For python I use click. Manually writing help page, which then gets parsed, then translated to command line parser seems a bit odd to me. In click, you simply annotate methods instead.

      1. 2

        Funny you should say that, one of the reasons I was happy to find this is that I don’t much like the way that Python click works, and there seemed to be few alternatives. It seems severely awkward to me that, in order to build a command suite application with click, I have to:

        1. Create a do-nothing top-level method annotated with @click.group()
        2. Create more top-level methods that do the things I actually want, and annotate them with @click.command()
        3. Call the add_command method on the do-nothing method, passing the subcommand methods
        4. Call the do-nothing group method to actually run it

        It all seems very messy and unintuitive. I could never guess how to set that up or add options to commands etc without reading the docs. On the other hand, writing the help page in a standard format, calling one command, and getting back a big dict you can use normally seems easy to remember and to lead to clean code. Maybe it doesn’t feel as fancy to if-else through all of the possible commands, but I’ll take not so fancy and easy to understand over something that makes no sense without the docs.

        1. 3

          Yes, click is not always exactly straightforward or intuitive. It also gets quite ugly when you have many options. Docopt seems nice, but there are many extra niceties in click I like: I can get prompt for missing required argument; I can get proper password input; it can check that argument is proper and accessible file; progressbars, input validators, etc …many nice little things that make it good and worthy those little inconveniences (at least for me).

          1. 1

            I see what you mean better now. I write mostly small helper scripts and utilities for myself for CLI, and haven’t felt the need for any of those features. I may think again about click if I feel the need for any of that kind of stuff.

        2. 1

          Docopts is great and has its domain of use, when things get more demanding I move to click. My rule of thumb is single file programs get Docopts while multifile ones get Click.