View Source CLIX.Feedback (clix v0.1.0)
The feedback generator.
It's designed to generate clear and compact feedbacks.
Quick start
iex> # 1. build a spec
iex> spec =
iex> CLIX.Spec.new(
iex> {:calc,
iex> %{
iex> summary: "A simple calculator.",
iex> description: """
iex> This calculator is for demostrating the funtionality of `CLIX.Feedback`.
iex> You can copy and play with it.
iex> """,
iex> cmds: [
iex> add: %{
iex> summary: "Add two number.",
iex> help: "add two number",
iex> args: [
iex> left: %{type: :integer, help: "the left number"},
iex> right: %{type: :integer, help: "the right number"}
iex> ]
iex> },
iex> minus: %{
iex> summary: "Minus two number.",
iex> help: "minus two number",
iex> args: [
iex> left: %{type: :integer, help: "the left number"},
iex> right: %{type: :integer, help: "the right number"}
iex> ]
iex> }
iex> ],
iex> opts: [
iex> debug: %{
iex> short: "d",
iex> long: "debug",
iex> type: :boolean,
iex> help: "enable debug logging"
iex> },
iex> verbose: %{
iex> short: "v",
iex> long: "verbose",
iex> type: :boolean,
iex> action: :count,
iex> help: "specify verbose level"
iex> }
iex> ],
iex> epilogue: """
iex> For more help on how to use CLIX, head to https://hex.pm/packages/clix
iex> """
iex> }}
iex> )
iex>
iex> # 2. generate doc
iex>
iex> # for root command
iex> CLIX.Feedback.help(spec)
iex>
iex> # for sub-command - add
iex> CLIX.Feedback.help(spec, [:add])
iex>
iex> # for sub-command - minus
iex> CLIX.Feedback.help(spec, [:minus])
The output:
root command
A simple calculator.
This calculator is for demostrating the funtionality of `CLIX.Feedback`.
You can copy and play with it.
Usage:
calc <COMMAND> [OPTIONS]
Commands:
add add two number
minus minus two number
Options:
-d, --debug enable debug logging
-v, --verbose... specify verbose level
For more help on how to use CLIX, head to https://hex.pm/packages/clix
sub-command add
Add two number.
Usage:
calc add [OPTIONS] <LEFT> <RIGHT>
Arguments:
<LEFT> the left number
<RIGHT> the right number
Options:
-d, --debug enable debug logging
-v, --verbose... specify verbose level
sub-command minus
Minus two number.
Usage:
calc minus [OPTIONS] <LEFT> <RIGHT>
Arguments:
<LEFT> the left number
<RIGHT> the right number
Options:
-d, --debug enable debug logging
-v, --verbose... specify verbose level
Summary
Types
@type subcmd_path() :: [CLIX.Spec.cmd_name()]
Functions
@spec format_error(CLIX.Parser.error()) :: String.t()
Formats a parsing error.
@spec help(CLIX.Spec.t(), subcmd_path()) :: String.t()
Generates comprehensive help.
The structure of generated content:
[summary]
[description]
[usage]
[sub-commands]
[positional arguments]
[optional arguments]
[epilogue]