module Tabular(T)
Overview
The Tabular
library.
Defined in:
tabular.crtabular/completers.cr
tabular/enums.cr
tabular/exceptions.cr
tabular/habit.cr
tabular/installer.cr
tabular/log.cr
tabular/tablet.cr
tabular/version.cr
Class Method Summary
-
.form(args : Array(String) = ARGV, &) : Bool
Define a set of [
Tablets
][Tabular::Tablets] and an optional [Habit#dispatch
][Tabular::Habit#dispatch]. -
.install!(args = ARGV, *, program : String = PROGRAM_NAME, command = Tabular.prompt)
Sends a completion script for the
<shell>
specified in args. -
.install?(arg = ARGV, *, prompt = "completion")
Retrun
true
and shift, if the first element in args i the prompt. -
.prompt : String
Return the name of the CLI argument that will prompt completions.
-
.prompt=(value : String)
Set the name of the CLI argument that will prompt completions.
-
.prompt?(args = ARGV)
Retrun
true
and shift, if the first element in args is the [Tabular.prompt
][Tabular.prompt].
Class Method Detail
Define a set of [Tablets
][Tabular::Tablets] and an optional [Habit#dispatch
][Tabular::Habit#dispatch].
Tabular.form do
option "--opt1" "-f", help: "a flag parameter"
option "--opt2" "-a", help: "a optiona with argument" { argument }
option "--opt2", help: "a flag with multiple arguments" do
argument "arg1_choice1", "arg1_choice2", "arg1_choice3"
argument "arg2_choice1", "arg2_choice2"
end
command "cmd1", "cmd1_alias", help: "a subcommand"
# An optional handler for command tablets
dispatch do |command|
if command.name == "cmd1"
Subcommand1.complete ARGV
end
end
end
Sends a completion script for the <shell>
specified in args.
- args: A list of user-specified arguments for the installer.
-
<shell>
: The shell to install the completions for (supports:bash
,fish
,zsh
).
-
--development <path>
: An alternate path to alias the CLI name to.
- program: The name of the CLI program. Best not to set this one.
- command: The subcommand the completion script will call to get completions.
Raises:
- [
Error::Argument
][Tabular::Error::Argument] — For malformed CLI arguments. - [
Error::Support
][Tabular::Error::Support] — If shell is unsupported.
Retrun true
and shift, if the first element in args i the prompt. to install a completion script.
Retrun true
and shift, if the first element in args is the [Tabular.prompt
][Tabular.prompt].