View Source DoIt.Output (do_it v0.6.1)
This module formats command help outputs.
Summary
Functions
It returns the allowed values from the given DoIt.Argument
.
It returns the description from DoIt.Argument
.
It formats the given DoIt.Argument
name attribute with spaces on the right, accordingly with the align
parameter.
It formats the given DoIt.Option
alias attribute.
It returns the allowed values from the given DoIt.Option
.
It formats the given DoIt.Option
default attribute.
It returns the description from DoIt.Option
.
It formats the given DoIt.Option
name attribute with spaces on the right, accordingly with the align
parameter.
It gets the length of the longer name attribute.
Functions
It returns the allowed values from the given DoIt.Argument
.
Examples
iex> DoIt.Output.format_argument_allowed_values(%DoIt.Argument{name: :op, type: :string, description: "Operation", allowed_values: ["+", "-", "*", "/"]})
" (Allowed Values: \"+\", \"-\", \"*\", \"/\")"
iex> DoIt.Output.format_argument_allowed_values(%DoIt.Argument{name: :verbose, type: :boolean, description: "Makes the command verbose"})
""
iex> DoIt.Output.format_argument_allowed_values(%DoIt.Argument{name: :number, type: :integer, description: "Numerical digit", allowed_values: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]})
" (Allowed Values: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)"
It returns the description from DoIt.Argument
.
Example
iex> DoIt.Output.format_argument_description(%DoIt.Argument{name: :verbose, type: :boolean, description: "Makes the command verbose"})
"Makes the command verbose"
It formats the given DoIt.Argument
name attribute with spaces on the right, accordingly with the align
parameter.
Examples
iex> DoIt.Output.format_argument_name(%DoIt.Argument{name: :verbose, type: :boolean, description: "Makes the command verbose"}, 15)
"verbose "
It formats the given DoIt.Option
alias attribute.
Examples
iex> DoIt.Output.format_option_alias(%DoIt.Option{name: :help, type: :boolean, description: "Shows the help command", alias: nil})
" "
iex> DoIt.Output.format_option_alias(%DoIt.Option{name: :help, type: :boolean, description: "Shows the help command", alias: :h})
"-h,"
It returns the allowed values from the given DoIt.Option
.
Examples
iex> DoIt.Output.format_option_allowed_values(%DoIt.Option{name: :op, type: :string, description: "Operation", allowed_values: ["+", "-", "*", "/"]})
" (Allowed Values: \"+\", \"-\", \"*\", \"/\")"
iex> DoIt.Output.format_option_allowed_values(%DoIt.Option{name: :verbose, type: :boolean, description: "Makes the command verbose"})
""
iex> DoIt.Output.format_option_allowed_values(%DoIt.Option{name: :number, type: :integer, description: "Numerical digit", allowed_values: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]})
" (Allowed Values: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)"
It formats the given DoIt.Option
default attribute.
Examples
iex> DoIt.Output.format_option_default(%DoIt.Option{name: :log_level, type: :string, description: "Set the logging level", alias: nil, default: "warn"})
" (Default: \"warn\")"
iex> DoIt.Output.format_option_default(%DoIt.Option{name: :skip_lines, type: :integer, description: "Lines to skip", alias: nil, default: 10})
" (Default: 10)"
iex> DoIt.Output.format_option_default(%DoIt.Option{name: :help, type: :boolean, description: "Shows the help command", alias: nil})
""
It returns the description from DoIt.Option
.
Examples
iex> DoIt.Output.format_option_description(%DoIt.Option{name: :help, type: :boolean, description: "Shows the help command", alias: nil})
"Shows the help command"
It formats the given DoIt.Option
name attribute with spaces on the right, accordingly with the align
parameter.
Examples
iex> DoIt.Output.format_option_name(%DoIt.Option{name: :help, type: :boolean, description: "Shows the help command", alias: nil}, 10)
"--help "
iex> DoIt.Output.format_option_name(%DoIt.Option{name: :log_level, type: :string, description: "Set the logging level", alias: nil}, 12)
"--log-level "
It gets the length of the longer name attribute.
Examples
iex> DoIt.Output.longer_name([%{name: "great"}, %{name: "greatest"}])
8
iex> DoIt.Output.longer_name([%{name: "Elixir"}, %{name: "Erlang"}, %{name: "DoIt"}, %{name: "OTP"}])
6