Fork me on GitHub
#clojure
<
2023-10-14
>
Ingy döt Net20:10:55

Is https://github.com/clojure/tools.cli/blob/master/README.md the best/only docs for parse-opts? I'm using it for the first time. One thing I'd like to know is if I can define an opt --foo such that --foo will have value true and --foo=bar will have value "bar". I've only skimmed that page above as a README seems like it shouldn't be the real doc...

Ingy döt Net20:10:22

I saw that one but > THIS IS A LEGACY FUNCTION and may be deprecated in the future. Please use clojure.tools.cli/parse-opts in new applications.

Ingy döt Net20:10:20

I guess I'm mostly looking for a detailed description of each keyword available for the cli-options data.

Ingy döt Net20:10:40

(doc clojure.tools.cli/parse-opts)
is it!

Ingy döt Net20:10:10

@U064X3EF3 is there an html version of (doc clojure.tools.cli/parse-opts) (besides the github source code)?

p-himik20:10:19

The "legacy function" warning is not for the whole page but for the cli function that happens to be documented the first.

Ingy döt Net20:10:43

I didn't get that 😕

phill00:10:21

The API docs' reference to https://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html suggests it does not have the --foo, --foo=bar ability

Ingy döt Net00:10:44

Thanks for following up, @U0HG4EHMH I couldn't figure out how to do it. Here's what I ended up with so far: https://github.com/yaml/yamlscript/blob/cli/cli/src/yamlscript/cli.clj#L14-L37 I was trying to do that with --compile but ended up using --compile-to=...

Ingy döt Net00:10:53

Not sure what they mean by > To specify an argument for a long option, write --name=value. This syntax enables a long option to accept an argument that is itself optional. in that link you posted...

Ingy döt Net00:10:17

Maybe --name= ?

seancorfield03:10:34

As maintainer of tools.cli, I'd be happy to hear specific, actionable feedback on the docs. Feel free to put suggestions/questions on http://ask.clojure.org -- it's a not a library I've needed to spend much time on since I took it over (originally, I took it on because we used it in several tools at work but those have all been simplified now so we've stopped using tools.cli).

👍 1
Ingy döt Net04:10:12

It's a pretty good getopt library. I've used a bunch of different ones and even written a couple. The one thing that would have helped me today is if the GitHub repo pointed to the documentation web page. I can probably make a PR for that tomorrow.

seancorfield05:10:47

It's a Contrib project so it doesn't accept PRs. As a Contrib project, it's generated API docs are available at https://clojure.github.io/tools.cli/ and the README does link to that (all the Contrib projects get API docs like that). http://cljdoc.org allows anyone to request API docs for any published library which is why https://cljdoc.org/d/org.clojure/tools.cli/ also exists).

seancorfield05:10:19

README: > Please see the https://github.com/clojure/tools.cli#example-usage for a more detailed example and refer to the docstring of parse-opts for comprehensive documentation: > > http://clojure.github.io/tools.cli/index.html#clojure.tools.cli/parse-opts

seancorfield05:10:34

I just added: > (as part of the http://clojure.github.io/tools.cli/) to that para which hopefully makes it a bit more obvious?