module Cli

Defined in:

cli.cr

Constant Summary

VERSION = {{ (`shards version /srv/crystaldoc.info/github-ralsina-markterm-v0.12.0/src`).chomp.stringify }}

Class Method Summary

Class Method Detail

def self.config_path(app_name : String) : String #

Default config file path for a tool, e.g. ~/.config/markterm/config.yml (or $XDG_CONFIG_HOME/markterm/config.yml)


[View source]
def self.option_flag(value : Docopt::OptionValue | Nil) : Bool #

Interpret an option as a boolean flag. docopt gives true for a flag given on the command line, false or nil otherwise; the config file can set true or false; environment variables are always strings, so "1", "true" or "yes" mean on, anything else off.


[View source]
def self.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.


[View source]
def self.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.


[View source]
def self.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 an Int32 (e.g. "margin: 20" or a numeric docopt default). Normalize those to the String docopt would have produced, ignoring values of other types.


[View source]
def self.read_source(source : String) : String #

Read the input file, or standard input when the file is "-"


[View source]