module CLI

Overview

To use the cli macro, include the CLI module into you code.

include CLI

Then call the macro mapping flags and subcommands to methods. Be sure to pass the macro ARGV, for production use.

def run_cli(argv=ARGV)
  cli argv, {
    "-o --output": set_output(String),
    "-h --help": show_help;
  }
end

To use the #ask method be sure to include it directly.

require "cli/ask"

ans = "Do you wanna? [Y/n]", "Y"

NOTE This is an early version, so please report any edge cases that need to be shored up, and offer suggestions for improvement. Thanks.

Extended Modules

Defined in:

cli.cr
cli/ask.cr
cli/version.cr

Constant Summary

VERSION = "0.2.0"

Macro Summary

Instance Method Summary

Macro Detail

macro cli(targs, topts) #

The cli macro in which the arguments array to parse must be passed.


[View source]

Instance Method Detail

def ask(prompt = nil, default_answer = nil) #

[View source]