class
Jargon::CLI
- Jargon::CLI
- Reference
- Object
Defined in:
jargon/cli.crjargon/config.cr
jargon/help.cr
Constructors
-
.from_file(path : String, program_name : String = "cli") : CLI
Create a CLI from a JSON schema file
-
.from_json(json : String, program_name : String = "cli") : CLI
Create a CLI from a JSON schema string
-
.from_yaml(yaml : String, program_name : String = "cli") : CLI
Create a CLI from a YAML schema string
- .new(schema : Schema, program_name : String = "cli")
- .new(program_name : String)
Instance Method Summary
- #bash_completion : String
-
#config_paths : Array(String)
Returns the list of config paths that would be searched
- #default_subcommand(name : String)
- #default_subcommand : String | Nil
- #fish_completion : String
- #help(subcommand : String) : String
- #help : String
-
#load_config(*, merge : Bool = true) : JSON::Any | Nil
Load config from standard locations.
- #parse(args : Array(String), input : IO, *, defaults : JSON::Any | Hash(String, JSON::Any) | Nil = nil) : Result
- #parse(args : Array(String), *, defaults : JSON::Any | Hash(String, JSON::Any) | Nil = nil) : Result
- #program_name : String
- #schema : Schema | Nil
- #subcommand(name : String, schema : Schema | String)
- #subcommand(name : String, cli : CLI)
- #subcommand_key(key : String)
- #subcommand_key : String
- #subcommands : Hash(String, Schema | CLI)
-
#validate(data : Hash(String, JSON::Any), subcommand : String | Nil = nil) : Array(String)
Validate data against a schema, returning any errors.
- #validate(result : Result) : Array(String)
- #zsh_completion : String
Constructor Detail
Create a CLI from a JSON schema file
Create a CLI from a JSON schema string
Create a CLI from a YAML schema string
Instance Method Detail
Load config from standard locations. Supports YAML (.yaml, .yml) and JSON (.json) files.
Paths searched (in order):
- ./.config/{program_name}.yaml/.yml/.json (project local, flat)
- ./.config/{program_name}/config.yaml/.yml/.json (project local, directory)
- $XDG_CONFIG_HOME/{program_name}.yaml/.yml/.json (user global, flat)
- $XDG_CONFIG_HOME/{program_name}/config.yaml/.yml/.json (user global, directory)
With merge: true (default), merges all configs found (project wins over user). With merge: false, returns first config found. Returns nil if no config file found.
Validate data against a schema, returning any errors. If no schema is provided, uses the CLI's root schema. For subcommand validation, pass the subcommand name (space-separated for nested).