module Jargon
Overview
Jargon builds a command-line parser from a JSON Schema: the schema is the
single source of truth for a CLI's options, types, validation, help text, and
shell completion. Start from Jargon.cli (flat CLI) or Jargon.new
(subcommand mode), then parse/run the arguments.
Defined in:
jargon.crjargon/cli.cr
jargon/completion.cr
jargon/config.cr
jargon/help.cr
jargon/result.cr
jargon/schema.cr
jargon/schema/property.cr
jargon/validator.cr
Constant Summary
-
VERSION =
"0.20.0"
Constructors
-
.new(program_name : String) : CLI
Create an empty CLI to attach subcommands to (subcommand mode).
Class Method Summary
-
.cli(program_name : String, *, json : String) : CLI
Create a CLI from a schema.
-
.cli(program_name : String, *, file : String) : CLI
Create a CLI from a schema.
-
.cli(program_name : String, *, yaml : String) : CLI
Create a CLI from a schema.
-
.config_warnings=(config_warnings : Bool)
Control whether config parse warnings are emitted to STDERR
-
.config_warnings? : Bool
Control whether config parse warnings are emitted to STDERR
-
.flatten(schema : String) : String
Flatten a schema by resolving all $ref pointers and removing $defs.
-
.from_file(path : String, program_name : String = "cli") : CLI
DEPRECATED Use Jargon.cli(program_name, file: path) instead
-
.from_json(json : String, program_name : String = "cli") : CLI
DEPRECATED Use Jargon.cli(program_name, json: schema) instead
-
.merge(sub : String, global : String) : String
Merge global schema properties into a subcommand schema.
Constructor Detail
Create an empty CLI to attach subcommands to (subcommand mode).
Class Method Detail
Create a CLI from a schema. The schema source is given by a named argument:
json:, yaml:, or file: (extension-detected). A multi-document schema
is auto-detected and loaded as subcommands.
Create a CLI from a schema. The schema source is given by a named argument:
json:, yaml:, or file: (extension-detected). A multi-document schema
is auto-detected and loaded as subcommands.
Create a CLI from a schema. The schema source is given by a named argument:
json:, yaml:, or file: (extension-detected). A multi-document schema
is auto-detected and loaded as subcommands.
Control whether config parse warnings are emitted to STDERR
Flatten a schema by resolving all $ref pointers and removing $defs. Useful for AI tool definitions that don't support $ref.
DEPRECATED Use Jargon.cli(program_name, file: path) instead
DEPRECATED Use Jargon.cli(program_name, json: schema) instead
Merge global schema properties into a subcommand schema. Properties from global are added to sub (sub takes precedence if both define same key).