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.cr
jargon/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

Class Method Summary

Constructor Detail

def self.new(program_name : String) : CLI #

Create an empty CLI to attach subcommands to (subcommand mode).


[View source]

Class Method Detail

def self.cli(program_name : String, *, json : String) : CLI #

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.


[View source]
def self.cli(program_name : String, *, file : String) : CLI #

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.


[View source]
def self.cli(program_name : String, *, yaml : String) : CLI #

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.


[View source]
def self.config_warnings=(config_warnings : Bool) #

Control whether config parse warnings are emitted to STDERR


[View source]
def self.config_warnings? : Bool #

Control whether config parse warnings are emitted to STDERR


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

Flatten a schema by resolving all $ref pointers and removing $defs. Useful for AI tool definitions that don't support $ref.


[View source]
def self.from_file(path : String, program_name : String = "cli") : CLI #

DEPRECATED Use Jargon.cli(program_name, file: path) instead


[View source]
def self.from_json(json : String, program_name : String = "cli") : CLI #

DEPRECATED Use Jargon.cli(program_name, json: schema) instead


[View source]
def self.merge(sub : String, global : String) : String #

Merge global schema properties into a subcommand schema. Properties from global are added to sub (sub takes precedence if both define same key).


[View source]