Liking cljdoc? Tell your friends :D

zensols.actioncli.parse

Parse action based command line arguments.

Parse action based command line arguments.
raw docstring

*dump-jvm-on-error*clj

Bind this from the REPL to avoid a system exit when testing the CLI.

Bind this from the REPL to avoid a system exit when testing the CLI.
raw docstring

*include-program-in-errors*clj

If non-nil add program name to error and warning messages in handle-exception and [[error-message]] and print-error-message.

If non-nil add program name to error and warning messages
in [[handle-exception]] and [[error-message]] and [[print-error-message]].
raw docstring

*log-error*clj

Log exceptions in handle-exception.

Log exceptions in [[handle-exception]].
raw docstring

*parse-context*clj

This context is bound when calling action bound functions. This is useful when other functions in this namespace need to be called with parse information.

This context is a map with the following keys:

This context is bound when calling action bound functions.  This is useful
when other functions in this namespace need to be called with parse
information.

This context is a map with the following keys:

* **:action-context** the context created with [[multi-action-context]]
or [[single-action-context]]
* **:arguments** the arguments passed to the parse function
* **:options** the parsed options
* **:single-action-mode?** whether the action context was created
with [[multi-action-context]] or [[single-action-context]]
raw docstring

*rethrow-error*clj

When not dying on error with *dump-jvm-on-error* also don't rethrow the exception in handle-exception.

When not dying on error with [[*dump-jvm-on-error*]] also don't rethrow the
exception in [[handle-exception]].
raw docstring

create-actionsclj

(create-actions action-context)

create-default-usage-formatclj

(create-default-usage-format)
(create-default-usage-format usage-format)

Create a function that formats the usage statement.

Create a function that formats the usage statement.
raw docstring

error-msgclj

(error-msg errors)

Print every element of the sequence errors. If there errors is a singleton then only print one in the common usage format.

Print every element of the sequence **errors**.  If there **errors** is a
singleton then only print one in the common usage format.
raw docstring

handle-exceptionclj

(handle-exception e)

Handle exceptions thrown from CLI actions.

See:

Handle exceptions thrown from CLI actions.

See:

* [[*include-program-in-errors*]]
* [[*rethrow-error*]]
* [[*log-error*]]
raw docstring

help-messageclj

(help-message & {:keys [action-key usage] :or {usage true}})

Generate the help message text and return it. The action-key is a keyword of the passed as a command to multi-action-context. By default the usage text is included unless the :usage key is false. If the :usage is the symbol only then only create the usage text and not the action/parameters.

Generate the help message text and return it.
The **action-key** is a keyword of the passed as a command
to [[multi-action-context]].  By default the usage text is included unless
the `:usage` key is `false`.  If the `:usage` is the symbol `only` then only
create the usage text and not the action/parameters.
raw docstring

help-optionclj

(help-option)
(help-option short long)

Return an option that provides version information.

Return an option that provides version information.
raw docstring

multi-action-contextclj

(multi-action-context actions
                      &
                      {:keys [global-actions help-option version-option
                              action-print-order print-help-fn usage-format-fn
                              no-action-fn default-arguments]
                       :or {help-option (help-option)
                            no-action-fn (fn [] (println (help-message)))}})

Create a multi-action context with map action. These don't include the name of the action on the command line and are typical UNIX like command lines (ex: ls, grep, etc).

The parameter is action is a list of list of symbols takes the form:

'((:action-name1 package1 action1)
  ...)

where action-name is a key, package is the package and action is the action definition.

Keys

  • help-option: the help action command, which defaults to help-option
  • version-option: usually created with version-option
  • global-actions: addition global actions in addition to the help and version options listed above
  • action-print-order: an optional sequence of action name keys indicating what order to print action help
  • print-help-fn: an optional function that takes a string argument of the generated option help to provide a way to customize the help message
  • usage-format-fn: generate the usage portion of the help message that takes the names of all action if generating multi-action usage or nil for single action usage messages
  • :no-action-fn a function to call when no action is given, defaults to printing the contents of help-message; set to nil to continue processing without an action
Create a multi-action context with map **action**.  These don't include the
  name of the action on the command line and are typical UNIX like command
  lines (ex: `ls`, `grep`, etc).

  The parameter is **action** is a list of list of symbols takes the form:
```
'((:action-name1 package1 action1)
  ...)
```
  where **action-name** is a key, **package** is the package and **action** is
  the action definition.

Keys
----
* **help-option:** the help action command, which defaults to [[help-option]]
* **version-option:** usually created with [[version-option]]
* **global-actions:** addition global actions in addition to the help and
  version options listed above
* **action-print-order:** an optional sequence of action name keys indicating
  what order to print action help
* **print-help-fn:** an optional function that takes a string argument of the
  generated option help to provide a way to customize the help message
* **usage-format-fn:** generate the usage portion of the help message that
  takes the names of all action if generating multi-action usage or nil for
  single action usage messages
* **:no-action-fn** a function to call when no action is given, defaults to
  printing the contents of [[help-message]]; set to `nil` to continue
  processing without an action
raw docstring

(print-error-message errors)

Print errors messages generated by [[error-message]].

Print errors messages generated by [[error-message]].
raw docstring

process-argumentsclj

(process-arguments action-context args)

Process the action line, which contains the action (action) and arguments args.

The action context is a map with actions. Actions in turn contains what to run when an action is given.

An example of an action context:

(defn- create-action-context []
  (multi-action-context
   '((:service com.example service start-server-action)
     (:repl zensols.actioncli repl repl-action))
   :version-option
   (->> (fn [] (println "version string"))
        version-option)
   :default-arguments ["service" "-p" "8080"]))

See the main document page for more info.

Process the action line, which contains the action (action) and arguments
  `args`.

  The action context is a map with actions.  Actions in turn contains what to
  run when an action is given.

  An example of an action context:

```clojure
(defn- create-action-context []
  (multi-action-context
   '((:service com.example service start-server-action)
     (:repl zensols.actioncli repl repl-action))
   :version-option
   (->> (fn [] (println "version string"))
        version-option)
   :default-arguments ["service" "-p" "8080"]))
```

  See the [main document page](https://github.com/plandes/clj-actioncli) for
  more info.
raw docstring

program-nameclj

(program-name)

Return the program name used for info/error message. This is set with set-program-name.

Return the program name used for info/error message.  This is set
with [[set-program-name]].
raw docstring

set-program-nameclj

(set-program-name program-name)

Set the program name used for info/error message.

Set the program name used for info/error message.
raw docstring

single-action-contextclj

(single-action-context action & options)

Create a single action context with map action. These don't include the name of the action on the command line and are typical UNIX like command lines (ex: ls, grep, etc).

The parameter is action is a list of symbols that takes the form:

'(package action)

where package is the package and action is the action definition.

See multi-action-context for the description of options.

Create a single action context with map **action**.  These don't include the
  name of the action on the command line and are typical UNIX like command
  lines (ex: `ls`, `grep`, etc).

  The parameter is **action** is a list of symbols that takes the form:
```
'(package action)
```
  where **package** is the package and **action** is the action definition.

  See [[multi-action-context]] for the description of **options**.
raw docstring

version-optionclj

(version-option print-fn)
(version-option print-fn short long)

Return an option that provides version information. The option uses print-fn to print the version of the program.

Return an option that provides version information.  The option uses
**print-fn** to print the version of the program.
raw docstring

with-exceptioncljmacro

(with-exception & forms)

Wrap a CLI forms in a try and call handle-exception if an exception occurs.

Wrap a CLI forms in a `try` and call [[handle-exception]] if an exception
occurs.
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close