module Cli
Defined in:
cli.crConstant Summary
-
VERSION =
{{ (`shards version /srv/crystaldoc.info/github-ralsina-markterm-v0.13.0/src`).chomp.stringify }}
Class Method Summary
-
.config_argv(app_name : String, argv : Array(String)) : Tuple(Array(String), String)
Handle the --config
option: pull it out of argv (both the "--config path" and "--config=path" forms; tokens after "--" are positional and never options) and return the stripped argv plus the config file path to use: the one given, or the tool's XDG default. -
.config_path(app_name : String) : String
Default config file path for a tool, e.g.
-
.option_flag(value : Docopt::OptionValue | Nil) : Bool
Interpret an option as a boolean flag: true when the flag was given on the command line or set to true in the config file or environment (docopt-config coerces env var values), false or nil otherwise.
-
.option_list(value : Docopt::OptionValue | Nil) : Array(String)
docopt returns a String when a repeatable option occurs once, and an Array(String) when it repeats (on the command line or through a list in the config file); normalize to an Array(String) either way.
-
.option_string(value : Docopt::OptionValue | Nil, fallback : String) : String
Same, for options that carry a docopt [default: ...] and must not end up nil: fall back to the documented default.
-
.option_string(value : Docopt::OptionValue | Nil) : String | Nil
docopt-config returns config file values with their YAML types, so an option documented as taking a string can come back as a number (e.g.
-
.read_source(source : String) : String
Read the input file, or standard input when the file is "-"
Class Method Detail
Handle the --config
Default config file path for a tool, e.g. ~/.config/markterm/config.yml (or $XDG_CONFIG_HOME/markterm/config.yml)
Interpret an option as a boolean flag: true when the flag was given on the command line or set to true in the config file or environment (docopt-config coerces env var values), false or nil otherwise.
docopt returns a String when a repeatable option occurs once, and an Array(String) when it repeats (on the command line or through a list in the config file); normalize to an Array(String) either way.
Same, for options that carry a docopt [default: ...] and must not end up nil: fall back to the documented default.
docopt-config returns config file values with their YAML types, so an option documented as taking a string can come back as a number (e.g. "margin: 20" as Int32, "margin: 20.5" as Float64, or a numeric docopt default). Normalize those to the String docopt would have produced, ignoring values of other types.
Read the input file, or standard input when the file is "-"