diff --git a/API.md b/API.md index 7c6be28..cdea376 100644 --- a/API.md +++ b/API.md @@ -19,12 +19,6 @@ - [`babashka.cli.exec`](#babashkacliexec) - [`-main`](#-main) - Main entrypoint for command line usage. - [`main`](#main) -- [`scratch`](#scratch) - - [`-main`](#-main-1) - - [`dns-get-spec`](#dns-get-spec) - - [`dns-spec`](#dns-spec) - - [`global-spec`](#global-spec) - - [`table`](#table) # babashka.cli @@ -66,7 +60,7 @@ Coerce string `s` using `f`. Does not coerce when `s` is not a string. Subcommand dispatcher. - Dispatches on longest matching command entry in [`table`](#table) by matching + Dispatches on longest matching command entry in `table` by matching subcommands to the `:cmds` vector and invoking the correspondig `:fn`. Table is in the form: @@ -91,21 +85,21 @@ Subcommand dispatcher. Each entry in the table may have additional [`parse-args`](#parse-args) options. For more information and examples, see [README.md](README.md#subcommands). -
[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L728-L760) +
[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L729-L761) ## `format-opts` ``` clojure (format-opts {:as cfg, :keys [indent], :or {indent 2}}) ``` -[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L627-L631) +[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L628-L632) ## `format-table` ``` clojure (format-table {:keys [rows indent], :or {indent 2}}) ``` -[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L565-L578) +[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L566-L579) ## `merge-opts` ``` clojure @@ -128,21 +122,21 @@ Merges babashka CLI options. (opts->table {:keys [spec order]}) ``` -[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L608-L625) +[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L609-L626) ## `pad` ``` clojure (pad len s) ``` -[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L543-L543) +[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L544-L544) ## `pad-cells` ``` clojure (pad-cells rows) ``` -[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L545-L551) +[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L546-L552) ## `parse-args` ``` clojure @@ -153,7 +147,7 @@ Merges babashka CLI options. Same as [`parse-opts`](#parse-opts) but separates parsed opts into `:opts` and adds `:cmds` and `:rest-args` on the top level instead of metadata. -
[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L514-L521) +
[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L515-L522) ## `parse-cmds` ``` clojure @@ -209,15 +203,15 @@ Parse the command line arguments `args`, a seq of strings. ```clojure (parse-opts ["foo" ":bar" "1"]) ;; => {:bar "1", :org.babashka/cli {:cmds ["foo"]}} - (parse-args [":b" "1"] {:aliases {:b :bar} :coerce {:bar parse-long}}) + (parse-opts [":b" "1"] {:aliases {:b :bar} :coerce {:bar parse-long}}) ;; => {:bar 1} - (parse-args ["--baz" "--qux"] {:spec {:baz {:desc "Baz"}} :restrict true}) + (parse-opts ["--baz" "--qux"] {:spec {:baz {:desc "Baz"}} :restrict true}) ;; => throws 'Unknown option --qux' exception b/c there is no :qux key in the spec ``` -
[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L266-L512) +
[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L267-L513) ## `rows` -[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L581-L583) +[source](https://github.com/babashka/cli/blob/main/src/babashka/cli.cljc#L582-L584) ## `spec->opts` ``` clojure @@ -252,32 +246,11 @@ Main entrypoint for command line usage. clojure -M:exec clojure.core prn :a 1 :b 2 ;;=> {:a "1" :b "2"} ``` -
[source](https://github.com/babashka/cli/blob/main/src/babashka/cli/exec.clj#L89-L102) +
[source](https://github.com/babashka/cli/blob/main/src/babashka/cli/exec.clj#L97-L110) ## `main` ``` clojure (main & args) ``` -[source](https://github.com/babashka/cli/blob/main/src/babashka/cli/exec.clj#L84-L87) -# scratch - - - - - -## `-main` -``` clojure - -(-main & args) -``` - -[source](https://github.com/babashka/cli/blob/main/src/scratch.clj#L15-L17) -## `dns-get-spec` -[source](https://github.com/babashka/cli/blob/main/src/scratch.clj#L8-L8) -## `dns-spec` -[source](https://github.com/babashka/cli/blob/main/src/scratch.clj#L7-L7) -## `global-spec` -[source](https://github.com/babashka/cli/blob/main/src/scratch.clj#L4-L6) -## `table` -[source](https://github.com/babashka/cli/blob/main/src/scratch.clj#L10-L13) +[source](https://github.com/babashka/cli/blob/main/src/babashka/cli/exec.clj#L92-L95) diff --git a/src/babashka/cli.cljc b/src/babashka/cli.cljc index 080c928..2749b3d 100644 --- a/src/babashka/cli.cljc +++ b/src/babashka/cli.cljc @@ -291,9 +291,9 @@ ```clojure (parse-opts [\"foo\" \":bar\" \"1\"]) ;; => {:bar \"1\", :org.babashka/cli {:cmds [\"foo\"]}} - (parse-args [\":b\" \"1\"] {:aliases {:b :bar} :coerce {:bar parse-long}}) + (parse-opts [\":b\" \"1\"] {:aliases {:b :bar} :coerce {:bar parse-long}}) ;; => {:bar 1} - (parse-args [\"--baz\" \"--qux\"] {:spec {:baz {:desc \"Baz\"}} :restrict true}) + (parse-opts [\"--baz\" \"--qux\"] {:spec {:baz {:desc \"Baz\"}} :restrict true}) ;; => throws 'Unknown option --qux' exception b/c there is no :qux key in the spec ``` "