Compare commits

..
49 Commits
Author SHA1 Message Date
tristan 4cce5cc45c Modified a few things:
- Finished implementing relative date parsing and migrated date parsing
  from Flag(T) to it's own dedicated module. Additionally added a
  the ability to do "recursive" relative operations for time searching.
- Additionally made a Struct & Enum for containing relative operations
  around dates.
- Added additional checks in App & CommandNode(T) around checking
  env_vars of flags & checking for duplicate commands
- Added a CommandMeta record to contain the classname of the
  CommandNode(T)
- Seperated out all of the monolitic files (command_node.cr & file.cr).
  Moved the base classes and records into their own files in the dir
  with the same name of their generic counterparts.
- Fixed a number of macro related bugs around Command.argument &
  CliGen.add_global_flag
- My ass hurts from sitting here for hours and doing these changes and
  arguing with claude over what needs to be done. Fun tho.
2026-08-30 22:13:39 -05:00
tristan f2d5c84f2b Made changes:
- Updated .gitignore to include specs
- Re-licensed to MPL-2.0 as I want any modifications to be pushed back
  to the main codebase so that the ecosystem can benefit from developer
  adoption
- Updated LICENSE & shard.yml with new license
- Changed author to personal email as this is not being done for my
  company
2026-08-30 12:52:16 -05:00
tristan fe6112795a Made several modifications:
- Added more complex date/time parsing for Time objects. This includes
  the ability to provide times in epoch format and several others with
  the ability to provide inline timezone offsets without external
  codebase works to convert them. Alongside this I added the ability to
  do relative time (ex: [+-]2 hours|minutes|days) (along with the ability
  to specify timezone if needed)
- Littered the entire codebase with Log object calls to show state of
  everything as the framework does it's stuff. Just needs Log to be
  configured in the codebase consuming my shard
- removed flag collection for use in displaying all flags in the app
  help output. So it will only show global flags & subcommands
- Changed CommandNode#get(short:) & get(long:) & flag?(arg : String)
  methods to check @flags -> @commands.@flags -> CliGen::GLOBAL_FLAGS
  when finding flags. Making it possible to not PRINT out the flag
  output but still be able to set values to a child flag recursively.
2026-08-29 18:51:08 -05:00
Tristan Ancelet fd4c0eb171 Had to fix default_value usage 2026-08-24 14:10:21 -05:00
Tristan Ancelet fda58a2ff7 Added a test to see if it works 2026-08-24 14:00:44 -05:00
Tristan Ancelet 777a1b992a Had to fix block.call to yield so that the compiler could be happy 2026-08-17 09:25:42 -05:00
tristan a17053f45c Added a specs for flag & arg. As well as changed a few ways I as handling cli args and determining how they're to be passed to each flag 2026-08-16 17:19:10 -05:00
Tristan Ancelet 6535753fa3 Had to fix some things in coerce 2026-08-14 15:55:28 -05:00
Tristan Ancelet 09389cb5e9 Added differnt check for default. Set it to empty string as a way of determining if a default was set. Ignoring empty strings 2026-08-14 15:01:04 -05:00
Tristan Ancelet d1746602b1 modified the way that the FlagMeta default string gets generated based on Array vs LITERALLY anything else 2026-08-14 14:57:05 -05:00
Tristan Ancelet 21462029e3 Fixed template 2026-08-14 14:34:10 -05:00
Tristan Ancelet 4a0dcb8b59 Had to fix expression to show type as {{...}} isn't expanded in macro expression betweeh {% ... %} 2026-08-14 14:19:38 -05:00
Tristan Ancelet 8780be3a42 Removed 'long' from macro expression 2026-08-14 14:18:02 -05:00
Tristan Ancelet fd510469ac Added allow_no_verification for users to bypass the 'must have options or validation' check. However, not doing so can cause unexpected failures where flags will begin consuming preceeding arguments 2026-08-14 14:14:53 -05:00
Tristan Ancelet f55cc25f2d Modified Command.argument to let the user provide a method call for runtime learning of options value. This will let the compiler check at compile time 2026-08-14 14:10:25 -05:00
Tristan Ancelet b05f49c2e8 Fixed something maybe 2026-08-14 14:00:31 -05:00
Tristan Ancelet d3ca70ea9e Added options for array checking of base types Strings/Int32/etc 2026-08-14 13:55:10 -05:00
Tristan Ancelet 697a0db3af Added debug message to print out a missing match + the format being matched 2026-08-12 16:34:16 -05:00
Tristan Ancelet a1a9c6fc04 Added format filter to enforce formatting on array objects 2026-08-12 16:26:35 -05:00
Tristan Ancelet ffde5165f7 Added format support for filtering arguments 2026-08-12 16:12:59 -05:00
Tristan Ancelet 53f510278c added thing 2026-08-12 13:12:09 -05:00
Tristan Ancelet e6d9306e69 Added exit & default to help if no main is specified 2026-08-12 13:10:30 -05:00
Tristan Ancelet 18c5a559b1 Added exit & default to help if no main is specified 2026-08-12 13:08:24 -05:00
Tristan Ancelet 28c45fae9e Added guard for empty @flags array in template 2026-08-12 13:01:41 -05:00
Tristan Ancelet f889aae5e1 added dynamic resizing of description for flag & the like 2026-08-12 12:56:59 -05:00
Tristan Ancelet e90d89689c Increased default spacing in commands and flags 2026-08-12 12:50:42 -05:00
Tristan Ancelet 9b3d823bc7 Comitting for testing 2026-08-12 12:43:44 -05:00
Tristan Ancelet d02eded273 Trying again 2026-08-12 12:40:08 -05:00
Tristan Ancelet fc592fee37 Trying again 2026-08-12 12:38:55 -05:00
Tristan Ancelet 47b4bfa494 had to fix syntax 2026-08-12 12:37:28 -05:00
Tristan Ancelet 1a2da86048 Allowed delim in macros 2026-08-12 12:36:23 -05:00
Tristan Ancelet 37c5083ae2 added def_init 2026-08-12 11:59:49 -05:00
Tristan Ancelet 976ed10f75 Added def_getter 2026-08-12 11:00:56 -05:00
Tristan Ancelet ea8ca62a63 Added StringIterpolation 2026-08-12 10:55:22 -05:00
Tristan Ancelet 0c7849dc7c Added options 2026-08-11 12:24:30 -05:00
Tristan Ancelet 47df89a6c1 Had to fix the selection macro. Was part of the way throught and skipped finishing it 2026-08-11 11:58:04 -05:00
Tristan Ancelet afd7ba7c7b Added options to Command.argument macro 2026-08-11 11:53:38 -05:00
Tristan Ancelet 8447a1ffbb Added prerun command annotation & implementation 2026-08-11 11:37:22 -05:00
Tristan Ancelet 4af08f8efe had to fix again 2026-08-11 11:24:22 -05:00
Tristan Ancelet 1085335c88 Had to add for lib setup 2026-08-11 11:22:02 -05:00
Tristan Ancelet 19ea00ef72 added a few things 2026-08-11 11:17:34 -05:00
tristanandClaude Sonnet 4.6 8d17de7434 Fix annotation key mismatch: validate -> validation in generate.cr
anno[:validate] was always nil; validation procs were never wired
into Flag(T).new. Correct key is :validation to match the field
name set by the argument macro in command/argument.cr.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Claude-Session: https://claude.ai/code/session_01ATnpoEGXj4RyuMoBLGWcjs
2026-08-10 13:12:12 -05:00
Tristan Ancelet 405303e4f8 updated .gitignor 2026-08-10 13:00:23 -05:00
Tristan Ancelet 29327a3e83 Got Array(T) working in flag.cr. Hacky stuff it is to convince the compiler that a value isn't going to be nil if I set it 2026-08-10 12:57:31 -05:00
tristanandClaude Sonnet 4.6 ac5711c0df Update .claude/settings.json with project permission allowlist
Allows crystal build/spec/run, shards, git read/write, and ls
without per-call prompts — consistent across machines.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Claude-Session: https://claude.ai/code/session_01ATnpoEGXj4RyuMoBLGWcjs
2026-08-10 08:02:58 -05:00
tristanandClaude Sonnet 4.6 519c8dcd44 Remove test binary and test.cr
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Claude-Session: https://claude.ai/code/session_01ATnpoEGXj4RyuMoBLGWcjs
2026-08-10 07:59:02 -05:00
tristanandClaude Sonnet 4.6 bc0f56fda9 Add .claude/, .gitignore, and update README
- .claude/settings.json: project-level Claude Code config
- .gitignore: ignores test binary, build artifacts, shards cache, tags
- README.md: expanded with usage example, dev commands, and AI assistance
  disclosure (Claude used for review/bug-checking, not code generation)

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Claude-Session: https://claude.ai/code/session_01ATnpoEGXj4RyuMoBLGWcjs
2026-08-10 07:58:15 -05:00
tristanandClaude Sonnet 4.6 6f31a5d27c object_rework: working MVP with runtime CommandNode tree
- BaseCommandNode (abstract) / CommandNode(T) split for heterogeneous tree
- Flag(T) with compile-time type branching, Parsable/Coercable modules
- Arg double-process invariant enforcement
- App.generate macro builds CommandNode tree from Command subclasses
- Command#initialize generated via macro finished, populates ivars from handler
- Reserved -h/--help enforcement in Flag#check!
- MatchType::Help added, SubCommand dispatch fixed
- design.adoc: added Planned Features (markdown docs, bash completion)
- Makefile: tabs, .DEFAULT_GOAL, doc_show target

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
2026-08-09 22:49:55 -05:00
tristan f5571cde73 Committing before test 2026-08-09 15:20:06 -05:00
74 changed files with 12152 additions and 498 deletions

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
{
"permissions": {
"allow": [
"Bash(crystal build*)",
"Bash(crystal spec*)",
"Bash(crystal run*)",
"Bash(shards install*)",
"Bash(shards update*)",
"Bash(git status*)",
"Bash(git diff*)",
"Bash(git log*)",
"Bash(git add*)",
"Bash(git commit*)",
"Bash(git push*)",
"Bash(git rm*)",
"Bash(rm -f test)",
"Bash(ls*)"
]
}
}
+9
View File
@@ -0,0 +1,9 @@
root = true
[*.cr]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
+21
View File
@@ -0,0 +1,21 @@
*
!CLAUDE.md
!lib/
!lib/cligen
!src/
!src/**
!shard.yml
!README.md
!DESIGN.md
!docs/
!docs/**
!Makefile
!LICENSE
!NOTICE
!spec/
!spec/**
!utils/
!utils/**
# ...but not the binary utils/flag_matrix.sh builds (later rules win).
utils/flag_matrix
+76
View File
@@ -0,0 +1,76 @@
# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Commands
```bash
# Run all specs
crystal spec
# Run a single spec file
crystal spec spec/command_spec.cr
# Type-check without running
crystal build src/cligen.cr --no-codegen
# Install dependencies
shards install
```
## What This Is
`cligen` is a Crystal **shard (library)** — not a standalone application. It wraps Crystal's built-in `OptionParser` with an annotation- and macro-driven system that auto-generates CLI parsers from class definitions. Users of the shard subclass `CliGen::Command` and annotate methods; the library generates the `OptionParser` wiring at compile time via Crystal macros.
## Architecture
### Entry point: `src/cligen.cr`
Defines the `CliGen` module. The `macro finished` hook calls `define_root_parser`, which scans all `CliGen::Command` subclasses at compile time and registers each as a subcommand on the root `OptionParser`. `CliGen.parse` runs the root parser.
`ADDITIONAL_DEFAULT_FLAGS` / `add_default_flag` let users inject extra flags into every parser (root and subcommand).
### Command definition: `src/cligen/command.cr`
`CliGen::Command` is the base class. When subclassed, `macro inherited` installs a `macro finished` block that triggers four code-generation macros in order:
1. `define_actions` — collects all `@[SubCommand]`-annotated class methods into `ACTIONS : Array(String)` and `@@action : String`.
2. `define_header` — builds the `HEADER` string (banner + examples) from `@[SubCommand]` and `@[CommandSelection]` annotation metadata.
3. `define_runner` (skipped if `@[CommandInfo(def_runner: false)]`) — generates a `self.run` method that dispatches on `@@action` or a selection variable via a `case` statement.
4. `define_action_setter` — generates `self.action=` with bounds-checking against `ACTIONS`.
#### Key macros on `Command`
- **`define_argument`** — declares a class-level variable (`@@`) and an annotated setter method (`@[CommandArgument]`). Handles `String`, `Bool`, `Int32`, `Array(String|Int32)`, and `Time`. Optional `check:` proc, `logger:` method, and `def_getter:` flag.
- **`define_selection`** — like `define_argument` but validates against a fixed list of values; annotated with `@[CommandArgument]` and participates in selection-based dispatch.
### Parser generation: `src/cligen/command/parser.cr`
`CliGen::Parser` is `extend`ed by `Command`. It provides `define_parser`, which generates `self.make_parser(parent_parser)`. That method:
1. Creates a subparser `OptionParser` with the command's `HEADER` as banner.
2. Wires `@[CommandSelection]`-annotated methods as `parser.on(name, description)` that set the selection variable.
3. Wires `@[SubCommand]`-annotated methods as subcommand strings that set `@@action`.
4. Wires `@[CommandArgument]`-annotated methods as `parser.on(short, long, description)` flag handlers.
5. Calls `CliGen.define_default_flags` (adds `-h`/`--help`, error handlers).
6. Registers the whole subparser on `parent_parser` under the command's lowercase class name.
### Annotations
| Annotation | Applied to | Purpose |
|---|---|---|
| `@[CommandInfo(description:, def_runner:)]` | Command subclass | Required; provides the description shown in root help; `def_runner: false` skips auto-generating `run` |
| `@[SubCommand(description:, examples:)]` | class method on Command | Marks a method as a dispatachable subcommand |
| `@[CommandArgument(short:, long:, description:, type:)]` | class method on Command | Generated automatically by `define_argument`/`define_selection`; drives parser wiring |
| `@[CommandSelection(selector:, description:, examples:)]` | class method on Command | Alternative to `SubCommand`; dispatches via a named selector variable instead of `@@action` |
| `@[CommandPreRun]` | class method on Command | Methods run unconditionally before dispatch inside `self.run` |
| `@[DefaultFlag]` | (reserved) | Defined but not currently used in generation |
### Supporting files
- `src/cligen/format.cr` — date/datetime format strings used by `Time` argument parsing.
- `src/cligen/regex.cr` — regexes for validating date/datetime input strings.
## Spec structure
`spec/command_spec.cr` uses Crystal's macro system heavily: most `it` blocks are generated at compile time by inspecting `CommandSubclass` via `@type` introspection. The `macro finished` wrapper around the entire `describe` block is required because `make_parser` and `run` don't exist until all `macro finished` hooks have fired.
+501
View File
@@ -0,0 +1,501 @@
# Crystal Cli Generator
**Author:** Tristan Ancelet
**Email:** tristanancelet@yahoo.com
## Overview
This document outlines the overall design of the CliGen shard & it's underlying classes/objects & their usecases.
## How it works/High-Level overview
Using crystal macros, you define the shape (arguments/flags, selections, work functions/subcommands, etc) and later on in `src/cligen/app/generate.cr` will use macros to (at compile time) generate `CommandNode(T)` objects & `Flag(T)` objects to contain your command/subcommand/arg parsing code from the data you provided in your `CliGen::Command` subclass.
## Architecture
The desire for this project is to provide a framework for generating commandline arg-parses & command dispatch built into a class/object.
The idea is to (much like `JSON::Serializable` & `YAML::Serializable`) is to use macros to help defining a Command object and abstract the command-line away from the codebase needing input from the user at init time.
### Command Objects
The core of this codebase is the `CliGen::Command` object.
This is the object that is meant to provide you the hook into being able to utilize the codebase. It is where you are able to define all of your expecetd arguments/flags & any selectables (aka, instance variable that you want the user to choose one value for. `ex: -f|--format json|yaml|ecr`).
To make this all possible we load the base class with macros that help define your variables & inform the framework how it needs to handle arguments being presented to your command object setters.
```crystal
require "cligen"
module MyModule
@[CliGen::CommandInfo(description: "My command that does cool things")]
class MyCommand < CliGen::Command
argument(myvar : Int32 = 23,
long: "--myvar VAR",
short: "-m",
description: "This tells the utility how many times to do thing",
validate: ->(v : Int32) : Bool { (1..23).includes?(v) }
)
argument(output_format : String = "ecr",
long: "--format FORMAT",
short: "-f",
description: "Inform the utility what output you want the data in",
options: %w[ json yaml ecr ]
)
DO_THING_EXAMPLES = [
"myutil mycommand do_thing --myvar 5"
]
subcommand do_thing, description: "Do the THING", examples: MyModule::MyCommand::DO_THING_EXAMPLES do
output = 0
@myvar.times do |i|
puts "thing done %i times" % [ i + 1 ]
output += i
end
puts "Total : %i" % output
end
end
CliGen::App.process
end
```
The examples like above provide a "DSL-esk" way of defining:
- Instance Variables,
- Short/Long flags
- Description of the flags (used in the help output as well)
- A verification proc/lambda for doing ad-hoc checks of the value provided by the user (essentially allowing you to implement your own option: key like in selection)
- Selections (currently compile-time and will open it up to runtime collecting of options later on based on defined annotations in the class)
- define subcommands of this current command
#### CliGen::CommandNode(T)
This is the "CliGen" representation of your command. Using crystal macros & generics when the CommandNode is created it will generate the internal Generic methods based on the defined command object and whether it has subcommands & main method, etc.
This is where all of the actual argument processing gets done in the `CliGen::CommandNode(T)#process(args : Array(CliGen::Arg))` method.
A main-loop of scoped parsing happens in it's `#process` method and if a child-command is detected `CliGen::Command -> MyModule::MyCommand -> MyModule::MyOtherCommand` it will gather all unprocessed arguments and will call that `CommandNode(T)`'s `#process` method.
This was done because it effectively keeps arguments scoped in their own contexts without causing something like OptionParser implementation having flag/argument bleed between commands and subcommands if multiple parsers are defined (aka OptionParser does not `#shift` arguments off as they are processed, which end up causing arguments to bleed into child instances).
Alongside it's main duty of handling CLI parsing of arguments it also serves to handle any framework related raises from `Flag(T)` (invalid values, incorrect custom data class behavior, internal errors, etc).
#### CliGen::App
This object is the root application that handles all initial execution from bare CLI arguments. It's just a subclass of `CommandNode(Nil)` (Subclassed with `Nil` for simplicity and to not deal with code duplication between macro generated `CommandNode(T)` and a custom `App` object (with them needing almost exactly the same methods).
For the majority of the process, this object just serves as the inital entrypoint to the CLI parsing and handles raises of any Framework related error classes (help output, exceptions related directly with the `CommandNode(T)` objects)
#### CliGen::Flag(T)
This is the object that handles option/argument parsing. It's a Generic Container who's internal layout changes depending on the type it's initalized with.
The only (currently as of writing this doc) types that are supported are:
- All Int permutations (Int8, UInt8, etc)
- All Float permutations (Float32, etc)
- String
- Bool
- Enum (*planned, but not implemented yet*)
- Time (strict formatting allowed)
- Array(T)
##### Time Limitations
The framework has some strict formatting for time arguments
It only accepts data in the following static formats:
- `%Y-%m-%d %H:%M:%S %z` (ex: `2026-08-30 19:00:00 +0000`)
* This specifies the date, time & timezone/offset (allowing you to customize the time)
- `%Y-%m-%d %H:%M:%S` (ex: `2026-08-30 19:00:00`)
* This specifies the date & time and will default to the local timezone of the device it's being run on (via `::Time.parse_local`) (would need much more conditionals but it gets the point accross)
- `%Y-%m-%d %z` (ex: `2026-08-30 +0000`)
* This specifies the date & timezone/offset, and will default to 00:00:00 for the time value
- `%Y-%m-%d` (ex: `2026-08-30`)
* This specifies the date, and will default to 00:00:00 for the time value and to the local timezone of the host (via `::Time.parse_local`)
- `@%s %z` (ex: `@1788122911 +0900`)
* This specifies the epoch time and the timezone you want the final `Time` object to be in (this gets the provided epoch time as UTC via `::Time.unix` and then setting the timezone to the provided offset)
- `@%s`
* This specifies the epoch time and via `::Time.unix` will default to `::Time::Location::UTC` for the timzone
However, minimal support for relative time has been added. Valid formats for this are:
- `[-+][0-9]+ (years|months|weeks|days|hours|minutes|seconds) %z` (ex: `+2 hours -0900`)
* This provides a relative time to look for and what timezone offset to convert to after the relative time is calculated via `::Time#in`
- `[-+][0-9]+ (years|months|weeks|days|hours|minutes|seconds)` (ex: `-2 hours`)
* This provides a relative time to look for and will default to the local timezone via `::Time.local`
- `[-+]%H:[-+]?%M:[-+]?%S %z` (ex: `-2:3:3 -0900`) (*planned but not currently implemented*)
* This provides a hour, minute and second to decrease/increase by (depending on each field's sign) and a timezone to convert to afterwards with `::Time#in`
- `[-+]%H:[-+]?%M %z` (ex: `-2:3 -0900`) (*planned but not currently implemented*)
* This provides a hour and minute to decrease/increase by (depending on each field's sign) and a timezone to convert to afterwards with `::Time#in`
- `[-+]%H:[-+]?%M:[-+]?%S` (ex: `-2:3:3`) (*planned but not currently implemented*)
* This provides a hour, minute and second to decrease/increase by (depending on each field's sign)
**Note:** Multiple human-readable operations
The relative operations for getting time relatively to the current time on the running system `+1 days` can be chained and the specific operation order is important when providing your ops.
So when doing multiple you can provide them like so
```
mycli mycmd --time '+2 weeks -1 month +30 days -0900`
```
This essentially grabs the local time (via `::Time.local`), setting it's timezone to the `-0900` offset, and then adding 2 weeks/14 days, jumping back a full month (dependant on the actual month) and then going forward 30 days.
**Note:** Relative operations short format (*planned but not implemented yet*)
For the `[-+]%H:[-+]?%M:[-+]?%S` formats if the sign's (`+-`) aren't provided for the `%M` or `%S` fields it will default to the sign provided to the `%H` field
##### Array(T) limitations
However, with Array(T) types there are a few limitations. The only supported in-place T-types are the core classes (Int*, Float*, String). However, provided you do the below extentions to your custom data class you can also use it as a data class with Arrays.
The framework (deliberately) limits the `:options` key to an array of individual choices that the user can provide instead of permutations of valid `Array(T)` values. So when providing an `Array(T)`
```crystal
require "cligen"
module MyModule
@[CliGen::CommandInfo(description: "Test Command")]
class MyCommand < CliGen::Command
argument(sources : Array(String),
description: "The source of all your pain",
options: %w[ tacos golang coffee ]
)
def main
@sources.each_with_index do |source, index|
puts "%d : %s" % [index + 1, source]
end
end
end
end
CliGen::App.process
```
Providing it in the array format will have the framework collapse it into just the Array(T) values so that they can be value-checked (`Array(T)#includes?(val)`)
Of which when an invalid value is provided the framework will abort directly if an invalid value is provided
```
(ins) tristan@arcanetome $: crystal run test4.cr -- mycommand --sources golang coffee pain
crystal-run-test4.tmp: 'pain' is not a valid value for --sources (valid: ["tacos", "golang", "coffee"])
```
However when run with valid values it has no issues
```
(ins) tristan@arcanetome $: crystal run test4.cr -- mycommand --sources golang coffee
1 : golang
2 : coffee
```
##### Custom Data Types
However, there is an API defined via the `CliGen::Parsable` and `CliGen::Coercable` modules that will allow you to customize parsing of a Custom DataType.
This is limited to parsing raw strings (of any format) into whatever your data is supposed to represent
```crystal
module MyModule
class MyData
extend CliGen::Parsable
extend CliGen::Coercable
@value : Int32
def initialize(value : String)
@value = value.to_i32
end
def self.parse_args(args : Array(CliGen::Arg))
arg = args.first
# Mark the argument as processed
arg.processed
new(arg.value)
end
def self.coerce(arg : String)
new(arg)
end
end
end
```
##### Override #to_s for CLI help readablility
If you do plan to use your custom data-type with the you will need to override the `#to_s(io : IO)` method to ensure that the help output can render it correctly
Example of a Custom DataType use in a `CliGen::Command` subclass argument/flag:
```crystal
require "cligen"
module MyModule
class MyData
extend CliGen::Coercable
extend CliGen::Parsable
@@instances = {} of String => MyData
getter name : String
getter work : Proc(Nil)
def initialize(@name, &@work)
unless @@instances.has_key?(@name)
@@instances[@name] = self
else
raise "HUH?"
end
end
def to_s(io : IO)
io << @name
end
def self.get(name : String)
@@instances[name]
end
def self.parse_args(args : Array(CliGen::Arg))
arg = args.first
arg.processed
get(arg.value)
end
def self.coerce(arg : String)
get(arg)
end
def self.all
@@instances.values
end
end
MyData.new("test") do
puts "Did a test"
end
MyData.new("really") do
puts "Yes really"
end
MyData.new("why") do
puts "Just because"
end
@[CliGen::CommandInfo(description: "Test Command")]
class MyCommand < CliGen::Command
argument(source : MyModule::MyData,
description: "The source of all your pain",
options: MyModule::MyData.all
)
def main
@source.work.call()
end
end
end
CliGen::App.process
```
Providing the overridden `#to_s` method makes the help output render your objects in a readable way
```
(ins) tristan@arcanetome $: crystal run test2.cr -- mycommand -h
Command: mycommand
Description: Test Command
Flags:
---------------------------------------------------------------
--source The source of all your pain (valid: test, really, why)
Global Flags
---------------------------------------------------------------
-v,--verbose Enable verbose output from program & help output (default: false)
Note: When wanting help output of any command you can provide the -h/--help flags or help command
(ins) tristan@arcanetome $: crystal run test2.cr -- mycommand --source why
Just because
```
Without the `#to_s` method overridden you'll get the crystal representation of your object instead (like below)
```
(ins) tristan@arcanetome $: crystal run test2.cr -- mycommand -h
Command: mycommand
Description: Test Command
Flags:
---------------------------------------------------------------
--source The source of all your pain (valid: #<MyModule::MyData:0x7f683ad0cc90>, #<MyModule::MyData:0x7f683ad0cc60>, #<MyModule::MyData:0x7f683ad0cc30>)
Global Flags
---------------------------------------------------------------
-v,--verbose Enable verbose output from program & help output (default: false)
Note: When wanting help output of any command you can provide the -h/--help flags or help command
```
Sill valid, but if you plan to make a registry based command/work/strategy selector you might want to override the `#to_s` method
##### CliGen::Coercable
```crystal
def self.coerce(arg : String)
new(arg)
end
```
The coerce method provides you the ability to parse a single string value into your class/datatype. This is generally only used when parsing from ENV VAR and when being used by parsing from an `Array(T)` type.
This should only be used in the case you need a simple datatype that can be learned from a single string.
##### CliGen::Parsable
```crystal
def self.parse_args(args : Array(CliGen::Arg))
arg = args.first
# Mark the argument as processed (required)
arg.processed
new(arg.value)
end
```
This method is used the most and is used for when using the bare class as the generic type in the `Flag(T)`. With this the `Flag(T)` will collect all provided arguments (cli arguments that weren't determined to be flags or subcommands) and pass them to your parse_args method so that you can parse them how you see fit and determine if the args provided by the user are enough and to be able to raise if data is not provided correctly/in the right format.
This gives the framework a way to allow you to extend the parser in your own custom way to allow for a "custom" format to be processed. However, it's very strict and you MUST properly mark the arguments as processed so that the mainloop won't double-process arguments passed to your custom parser. However, this won't happen as in the Flag(T) I am doing a check to ensure that args were processed after passing it to your code.
#### CliGen::Arg
This object serves as a wrapper around ARGV objects/strings/items and is used to keep track of argument processing to ensure that no argument is double-processed/re-processed and enforces this by the internal raise if the `Arg#processed` is called multiple times (mostly did it for MY sanity as doing offset math of ARGV was causing me anxiety so this was the only acceptible method in my opinion on a possibly MASSIVE set of args that could be provided via the CLI).
## Planned Features
### Markdown Documentation Generation
Since all command metadata is present in annotations at compile time (`@[CliGen::CommandInfo]`, `@[CliGen::SubCommand]`, `@[CliGen::Argument]`, `@[CliGen::Selection]`), the framework can walk the same structures that `generate.cr` already walks and render them into a Markdown document instead of a `CommandNode` tree.
The generation would be driven by a `macro finished` block (similar to `generate.cr`) that emits a `self.generate_docs` class method on `App`. This method walks every `Command` subclass and its annotations to produce a structured document.
Proposed output structure:
```
# <AppName>
## Commands
### mycommand
<CommandInfo description>
#### Help
<CommandNode help output>
#### Flags
| Flag | Type | Default | Description |
|----------------|-------|---------|-------------|
| -m,--myvar VAR | Int32 | 23 | ... |
#### Subcommands
- `do_thing` — <description>
- Examples: ...
```
Implementation notes:
* Driven by a `--generate-docs` global flag or a dedicated class method (if the utility was compiled with the INCLUDE_DOC=true ENV VAR set)
* ECR templates (already pulled in) are the natural rendering mechanism
* The same annotation data powers both runtime help output and the doc generator, keeping them in sync automatically
### Bash Autocompletion Generation
Since all command names and flag names are known at compile time, a complete bash completion script can be generated statically — no runtime `--completions` endpoint needed.
The approach is a hidden `--generate-completion bash` flag (potentially extended to `zsh`/`fish` later) that prints a ready-to-install completion script to stdout.
Proposed completion script shape:
```bash
_myapp() {
local cur="${COMP_WORDS[COMP_CWORD]}"
local prev="${COMP_WORDS[COMP_CWORD-1]}"
case "${COMP_WORDS[1]}" in
mycommand)
COMPREPLY=($(compgen -W "--myvar -m --format -f" -- "$cur"))
;;
*)
COMPREPLY=($(compgen -W "mycommand myothercommand" -- "$cur"))
;;
esac
}
complete -F _myapp myapp
```
Implementation notes:
* Script body generated at compile time via a `macro finished` walk of `Command.subclasses`
* `@[CliGen::Selection]` options (`%w[json yaml ecr]`) can be included as valid completions for their flag
* Install path: `myapp --generate-completion bash > ~/.bash_completion.d/myapp` or printed with instructions
* Same annotation data used by the doc generator, so both stay in sync with the command definition
### JSON-RPC like execution
This is a LATE (post v1.0) feature. It takes the same format and instead of a CLI argument
```json
{
"method": "myclass.mysubcommand",
"params": {
"myvar": 3,
"format": "json"
}
}
```
Essentially, this would (instead of tying directly into a command execution module would essentially wrap around App.process and provide them as Array(String) args to App.process(args : Array(String)) to allow the entire app execution to happen.
The json snippet above would essentially be the same as
```crystal
App.process(["--myvar", "3", "--format" , "json", "myclass", "mysubcommand"])
```
However, the design is bound to change as the complexity alone to make the command execution be "similar but different" as any responses would like need to be returned back in JSON-RPC style back to the calling process.
Alongside to generating the JSON-RPC style documenatation for a calling process to know what methods are defined and what type of params are accessible and what types they accept.
This is a LONG TERM goal as it would be pretty neat to implement.
+198 -17
View File
@@ -1,21 +1,202 @@
MIT License
Copyright (c) 2026 Tristan Ancelet <[email protected]>
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
1. Definitions.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+22
View File
@@ -0,0 +1,22 @@
DOC_DIR := docs
PROJECT_NAME := CliGenerator
.DEFAULT_GOAL := spec
.PHONY: spec spec_silent doc doc_show
.SILENT: spec spec_silent doc doc_show
.DEFAULT:
@echo "BRUV "$@" isn't a valid target"
spec:
crystal spec -v
spec_silent:
crystal spec
doc:
crystal doc --project-name "$(PROJECT_NAME)" --output "$(DOC_DIR)"
echo "Done Generating docs"
doc_show:
cd "$(DOC_DIR)"; python -m http.server
+5
View File
@@ -0,0 +1,5 @@
cligen
Copyright 2026 Tristan Ancelet
This product includes software developed by Tristan Ancelet
(https://git.arcanium.tech/tristan/cligen).
+131 -3
View File
@@ -1,6 +1,10 @@
# CliGenerator
# cligen
This is a crystal project to manage setting up OptionParser objects based around "Command" objects and arguments you define inside them.
A Crystal shard that generates CLI parsers from class definitions using annotations and macros. Define your commands as classes; cligen builds the runtime parse tree.
## How It Works
Subclass `CliGen::Command`, annotate your instance variables with `@[CliGen::Argument]` or `@[CliGen::Selection]`, and register the command with an `CliGen::App`. At compile time, macros inspect the annotations and generate typed `Flag(T)` objects; at runtime, `CliGen::App.process` walks the `CommandNode` tree to route arguments, populate your command instance, and dispatch to the right method.
## Installation
@@ -14,12 +18,136 @@ This is a crystal project to manage setting up OptionParser objects based around
2. Run `shards install`
## Usage
```crystal
require "cligen"
@[CliGen::CommandInfo(description: "Greet someone")]
class Greet < CliGen::Command
@[CliGen::Argument(short: "-n", long: "--name VALUE", description: "Name to greet")]
@name : String = "world"
argument(otherval : String = "abc",
long: "--other",
short: "-o",
options: %w[ abc def ghi ],
description: "This provides a way of setting the second string taht is printed"
)
argument(myvars : Array(String) = [ "a" ],
short: "-m",
options: %w[ a b c ],
description: "Provide multiple things to be printed out in the main function"
)
def main
puts "1) Hello, #{@name}!"
puts "2) #{@otherval}"
@myvars.each_with_index do |var, index|
puts "%d) %s" % [ 3 + index, var ]
end
end
end
CliGen::App.process
```
```
$ myapp greet --name Alice -m a a -m a,a,b
1) Hello, Alice!
2) abc
3) a
4) a
5) a
6) a
7) b
```
Full API documentation and design notes are in [`design.adoc`](design.adoc).
## Architecture
As a short overview, this projects makes HEAVY use of Crystal macros to learn the shape of your project & command subclasses.
Subclassing to `CliGen::Command` injects macros into your class that provides you user friendly DSLs/Macros for defining arguments/flags & subcommands. This is later used in the library `src/cligen/app/generate.cr` to generate a object graph of your commands and all annotated "arguments/flags" and stores them in a tree from the App object itself.
This allows the project to "learn" your project & generate a command tree from the defined data.
The MAJORITY of stdlib types (Int*, Float*, String, Bool & Time) are all supported in-place (as these are the primary data-types you might try to comsume from the CLI. However, custom data types are supported provided you extend the class's metaclass with `CliGen::Coercable` && `CliGen::Parsable` modules and define the `self.parse_args(args : Array(CliGen::Arg)` and `self.coerce(arg : String)` class methods.
EX:
```crystal
module MyModule
class MyData
extend CliGen::Parsable
extend CliGen::Coercable
@value : Int32
def initialize(value : String)
@value = value.to_i32
end
def self.parse_args(args : Array(CliGen::Arg))
arg = args.first
# Mark the argument as processed
arg.processed
new(arg.value)
end
def self.coerce(arg : String)
new(arg)
end
end
end
```
Coercable Method:
-----------------
```crystal
def self.coerce(arg : String)
new(arg)
end
```
The coerce method provides you the ability to parse a single string value into your class/datatype. This is generally only used when parsing from ENV VAR and when being used by parsing from an Array(T) type.
This should only be used in the case you need a simple datatype that can be learned from a single string.
Parsable Method:
----------------
```crystal
def self.parse_args(args : Array(CliGen::Arg))
arg = args.first
# Mark the argument as processed (required)
arg.processed
new(arg.value)
end
```
This method is used the most and is used for when using the bare class as the generic type in the Flag(T). With this the Flag(T) will collect all provided arguments (cli arguments that weren't determined to be flags or subcommands) and pass them to your parse_args method so that you can parse them how you see fit and determine if the args provided by the user are enough and to be able to raise if data is not provided correctly/in the right format.
This gives the framework a way to allow you to extend the parser in your own custom way to allow for a "custom" format to be procesed. However, it's very strict and you MUST properly mark the arguments as processed so that the mainloop won't double-process arguments passed to your custom parser. However, this won't happen as in the Flag(T) I am doing a check to ensure that args were processed after passing it to your code.
## Development
```bash
# Type-check without running
crystal build src/cligen.cr --no-codegen
# Run specs
crystal spec
```
## AI Assistance Disclosure
This project uses [Claude Code](https://claude.ai/code) as a development aid — specifically for catching bugs, spotting typos, reviewing implementations, and talking through design decisions. All architecture decisions, code, and design are written by the author. Claude is used the way one might use a second pair of eyes on a diff, not as a code generator.
`CLAUDE.md` at the repo root documents the project structure for Claude's context. `.claude/` holds project-level Claude Code settings.
## Contributors
- [Tristan Ancelet](https://git.arcanium.tech/tristan) - creator and maintainer
+177
View File
@@ -0,0 +1,177 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Crystal Docs 1.20.3">
<meta name="crystal_docs.project_version" content="object_rework-dev">
<meta name="crystal_docs.project_name" content="CliGenerator">
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/doc.js"></script>
<meta name="repository-name" content="CliGenerator">
<title>CliGenerator object_rework-dev</title>
<script type="text/javascript">
CrystalDocs.base_path = "";
</script>
</head>
<body>
<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill="currentColor" fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>
<input type="checkbox" id="sidebar-btn">
<label for="sidebar-btn" id="sidebar-btn-label">
<svg class="open" xmlns="http://www.w3.org/2000/svg" height="2em" width="2em" viewBox="0 0 512 512"><title>Open Sidebar</title><path fill="currentColor" d="M80 96v64h352V96H80zm0 112v64h352v-64H80zm0 112v64h352v-64H80z"></path></svg>
<svg class="close" xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" viewBox="0 0 512 512"><title>Close Sidebar</title><path fill="currentColor" d="m118.6 73.4-45.2 45.2L210.7 256 73.4 393.4l45.2 45.2L256 301.3l137.4 137.3 45.2-45.2L301.3 256l137.3-137.4-45.2-45.2L256 210.7Z"></path></svg>
</label>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
<input type="search" class="search-input" placeholder="Search..." spellcheck="false" aria-label="Search">
</div>
<div class="project-summary">
<h1 class="project-name">
<a href="index.html">
CliGenerator
</a>
</h1>
<span class="project-version">
object_rework-dev
</span>
</div>
</div>
<div class="search-results hidden">
<ul class="search-list"></ul>
</div>
<div class="types-list">
<ul>
<li class="parent " data-id="CliGenerator/CliGen" data-name="cligen">
<a href="CliGen.html">CliGen</a>
<ul>
<li class=" " data-id="CliGenerator/CliGen/AdditionalDefaultFlag" data-name="cligen::additionaldefaultflag">
<a href="CliGen/AdditionalDefaultFlag.html">AdditionalDefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/App" data-name="cligen::app">
<a href="CliGen/App.html">App</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Arg" data-name="cligen::arg">
<a href="CliGen/Arg.html">Arg</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Argument" data-name="cligen::argument">
<a href="CliGen/Argument.html">Argument</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/BaseFlag" data-name="cligen::baseflag">
<a href="CliGen/BaseFlag.html">BaseFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Command" data-name="cligen::command">
<a href="CliGen/Command.html">Command</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandInfo" data-name="cligen::commandinfo">
<a href="CliGen/CommandInfo.html">CommandInfo</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandNode" data-name="cligen::commandnode">
<a href="CliGen/CommandNode.html">CommandNode</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/DefaultFlag" data-name="cligen::defaultflag">
<a href="CliGen/DefaultFlag.html">DefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Flag" data-name="cligen::flag(t)">
<a href="CliGen/Flag.html">Flag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Format" data-name="cligen::format">
<a href="CliGen/Format.html">Format</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/MatchType" data-name="cligen::matchtype">
<a href="CliGen/MatchType.html">MatchType</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/ProxyCommand" data-name="cligen::proxycommand">
<a href="CliGen/ProxyCommand.html">ProxyCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Regex" data-name="cligen::regex">
<a href="CliGen/Regex.html">Regex</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Selection" data-name="cligen::selection">
<a href="CliGen/Selection.html">Selection</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/SubCommand" data-name="cligen::subcommand">
<a href="CliGen/SubCommand.html">SubCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Trigger" data-name="cligen::trigger">
<a href="CliGen/Trigger.html">Trigger</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="main-content">
<h1 class="type-name">
404 Not Found
</h1>
<p>
This page is unavailable in this version of the API docs.
</p>
<p>
You can use the sidebar to search for your page, or try a different
Crystal version.
</p>
</div>
</body>
</html>
+363
View File
@@ -0,0 +1,363 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Crystal Docs 1.20.3">
<meta name="crystal_docs.project_version" content="object_rework-dev">
<meta name="crystal_docs.project_name" content="CliGenerator">
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/doc.js"></script>
<meta name="repository-name" content="CliGenerator">
<title>CliGen - CliGenerator object_rework-dev</title>
<script type="text/javascript">
CrystalDocs.base_path = "";
</script>
</head>
<body>
<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill="currentColor" fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>
<input type="checkbox" id="sidebar-btn">
<label for="sidebar-btn" id="sidebar-btn-label">
<svg class="open" xmlns="http://www.w3.org/2000/svg" height="2em" width="2em" viewBox="0 0 512 512"><title>Open Sidebar</title><path fill="currentColor" d="M80 96v64h352V96H80zm0 112v64h352v-64H80zm0 112v64h352v-64H80z"></path></svg>
<svg class="close" xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" viewBox="0 0 512 512"><title>Close Sidebar</title><path fill="currentColor" d="m118.6 73.4-45.2 45.2L210.7 256 73.4 393.4l45.2 45.2L256 301.3l137.4 137.3 45.2-45.2L301.3 256l137.3-137.4-45.2-45.2L256 210.7Z"></path></svg>
</label>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
<input type="search" class="search-input" placeholder="Search..." spellcheck="false" aria-label="Search">
</div>
<div class="project-summary">
<h1 class="project-name">
<a href="index.html">
CliGenerator
</a>
</h1>
<span class="project-version">
object_rework-dev
</span>
</div>
</div>
<div class="search-results hidden">
<ul class="search-list"></ul>
</div>
<div class="types-list">
<ul>
<li class="parent open current" data-id="CliGenerator/CliGen" data-name="cligen">
<a href="CliGen.html">CliGen</a>
<ul>
<li class=" " data-id="CliGenerator/CliGen/AdditionalDefaultFlag" data-name="cligen::additionaldefaultflag">
<a href="CliGen/AdditionalDefaultFlag.html">AdditionalDefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/App" data-name="cligen::app">
<a href="CliGen/App.html">App</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Arg" data-name="cligen::arg">
<a href="CliGen/Arg.html">Arg</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Argument" data-name="cligen::argument">
<a href="CliGen/Argument.html">Argument</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/BaseFlag" data-name="cligen::baseflag">
<a href="CliGen/BaseFlag.html">BaseFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Command" data-name="cligen::command">
<a href="CliGen/Command.html">Command</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandInfo" data-name="cligen::commandinfo">
<a href="CliGen/CommandInfo.html">CommandInfo</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandNode" data-name="cligen::commandnode">
<a href="CliGen/CommandNode.html">CommandNode</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/DefaultFlag" data-name="cligen::defaultflag">
<a href="CliGen/DefaultFlag.html">DefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Flag" data-name="cligen::flag(t)">
<a href="CliGen/Flag.html">Flag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Format" data-name="cligen::format">
<a href="CliGen/Format.html">Format</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/MatchType" data-name="cligen::matchtype">
<a href="CliGen/MatchType.html">MatchType</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/ProxyCommand" data-name="cligen::proxycommand">
<a href="CliGen/ProxyCommand.html">ProxyCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Regex" data-name="cligen::regex">
<a href="CliGen/Regex.html">Regex</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Selection" data-name="cligen::selection">
<a href="CliGen/Selection.html">Selection</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/SubCommand" data-name="cligen::subcommand">
<a href="CliGen/SubCommand.html">SubCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Trigger" data-name="cligen::trigger">
<a href="CliGen/Trigger.html">Trigger</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="main-content">
<h1 class="type-name">
<span class="kind">
module
</span> CliGen
</h1>
<h2>
<a id="defined-in" class="anchor" href="#defined-in">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Defined in:
</h2>
cligen.cr
<br/>
cligen/annotations.cr
<br/>
cligen/app.cr
<br/>
cligen/arg.cr
<br/>
cligen/command.cr
<br/>
cligen/command/argument.cr
<br/>
cligen/command/selection.cr
<br/>
cligen/command/subcommand.cr
<br/>
cligen/command/trigger.cr
<br/>
cligen/command_node.cr
<br/>
cligen/flag.cr
<br/>
cligen/generate.cr
<br/>
cligen/match_type.cr
<br/>
<h2>
<a id="constant-summary" class="anchor" href="#constant-summary">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Constant Summary
</h2>
<dl>
<dt class="entry-const" id="ADDITIONAL_DEFAULT_FLAGS">
<strong>ADDITIONAL_DEFAULT_FLAGS</strong> = <code><span class="o">[]</span> <span class="k">of</span> <span class="t">AdditionalDefaultFlag</span></code>
</dt>
<dt class="entry-const" id="APPNAME">
<strong>APPNAME</strong> = <code><span class="t">File</span>.basename(<span class="t">PROGRAM_NAME</span>)</code>
</dt>
<dt class="entry-const" id="VERSION">
<strong>VERSION</strong> = <code><span class="s">&quot;0.1.0&quot;</span></code>
</dt>
</dl>
<h2>
<a id="class-method-summary" class="anchor" href="#class-method-summary">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Class Method Summary
</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#add_default_flag%28short%3AString%3D%22%22%2Clong%3AString%3D%22%22%2Cdescription%3AString%3D%22%22%2C%26work%3AString-%3E%29-class-method" class="signature"><strong>.add_default_flag</strong>(short : String = <span class="s">&quot;&quot;</span>, long : String = <span class="s">&quot;&quot;</span>, description : String = <span class="s">&quot;&quot;</span>, &work : String -> )</a>
</li>
</ul>
<div class="methods-inherited">
</div>
<h2>
<a id="class-method-detail" class="anchor" href="#class-method-detail">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Class Method Detail
</h2>
<div class="entry-detail" id="add_default_flag(short:String=&quot;&quot;,long:String=&quot;&quot;,description:String=&quot;&quot;,&amp;work:String-&gt;)-class-method">
<div class="signature">
def self.<strong>add_default_flag</strong>(short : String = <span class="s">&quot;&quot;</span>, long : String = <span class="s">&quot;&quot;</span>, description : String = <span class="s">&quot;&quot;</span>, &work : String -> )
<a class="method-permalink" href="#add_default_flag%28short%3AString%3D%22%22%2Clong%3AString%3D%22%22%2Cdescription%3AString%3D%22%22%2C%26work%3AString-%3E%29-class-method">#</a>
</div>
<br/>
<div>
</div>
</div>
</div>
</body>
</html>
+451
View File
@@ -0,0 +1,451 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Crystal Docs 1.20.3">
<meta name="crystal_docs.project_version" content="object_rework-dev">
<meta name="crystal_docs.project_name" content="CliGenerator">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<meta name="repository-name" content="CliGenerator">
<title>CliGen::AdditionalDefaultFlag - CliGenerator object_rework-dev</title>
<script type="text/javascript">
CrystalDocs.base_path = "../";
</script>
</head>
<body>
<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill="currentColor" fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>
<input type="checkbox" id="sidebar-btn">
<label for="sidebar-btn" id="sidebar-btn-label">
<svg class="open" xmlns="http://www.w3.org/2000/svg" height="2em" width="2em" viewBox="0 0 512 512"><title>Open Sidebar</title><path fill="currentColor" d="M80 96v64h352V96H80zm0 112v64h352v-64H80zm0 112v64h352v-64H80z"></path></svg>
<svg class="close" xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" viewBox="0 0 512 512"><title>Close Sidebar</title><path fill="currentColor" d="m118.6 73.4-45.2 45.2L210.7 256 73.4 393.4l45.2 45.2L256 301.3l137.4 137.3 45.2-45.2L301.3 256l137.3-137.4-45.2-45.2L256 210.7Z"></path></svg>
</label>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
<input type="search" class="search-input" placeholder="Search..." spellcheck="false" aria-label="Search">
</div>
<div class="project-summary">
<h1 class="project-name">
<a href="../index.html">
CliGenerator
</a>
</h1>
<span class="project-version">
object_rework-dev
</span>
</div>
</div>
<div class="search-results hidden">
<ul class="search-list"></ul>
</div>
<div class="types-list">
<ul>
<li class="parent open current" data-id="CliGenerator/CliGen" data-name="cligen">
<a href="../CliGen.html">CliGen</a>
<ul>
<li class=" current" data-id="CliGenerator/CliGen/AdditionalDefaultFlag" data-name="cligen::additionaldefaultflag">
<a href="../CliGen/AdditionalDefaultFlag.html">AdditionalDefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/App" data-name="cligen::app">
<a href="../CliGen/App.html">App</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Arg" data-name="cligen::arg">
<a href="../CliGen/Arg.html">Arg</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Argument" data-name="cligen::argument">
<a href="../CliGen/Argument.html">Argument</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/BaseFlag" data-name="cligen::baseflag">
<a href="../CliGen/BaseFlag.html">BaseFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Command" data-name="cligen::command">
<a href="../CliGen/Command.html">Command</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandInfo" data-name="cligen::commandinfo">
<a href="../CliGen/CommandInfo.html">CommandInfo</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandNode" data-name="cligen::commandnode">
<a href="../CliGen/CommandNode.html">CommandNode</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/DefaultFlag" data-name="cligen::defaultflag">
<a href="../CliGen/DefaultFlag.html">DefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Flag" data-name="cligen::flag(t)">
<a href="../CliGen/Flag.html">Flag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Format" data-name="cligen::format">
<a href="../CliGen/Format.html">Format</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/MatchType" data-name="cligen::matchtype">
<a href="../CliGen/MatchType.html">MatchType</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/ProxyCommand" data-name="cligen::proxycommand">
<a href="../CliGen/ProxyCommand.html">ProxyCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Regex" data-name="cligen::regex">
<a href="../CliGen/Regex.html">Regex</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Selection" data-name="cligen::selection">
<a href="../CliGen/Selection.html">Selection</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/SubCommand" data-name="cligen::subcommand">
<a href="../CliGen/SubCommand.html">SubCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Trigger" data-name="cligen::trigger">
<a href="../CliGen/Trigger.html">Trigger</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="main-content">
<h1 class="type-name">
<span class="kind">
struct
</span> CliGen::<wbr>AdditionalDefaultFlag
</h1>
<ul class="superclass-hierarchy"><li class="superclass"><a href="../CliGen/AdditionalDefaultFlag.html">CliGen::AdditionalDefaultFlag</a></li><li class="superclass">Struct</li><li class="superclass">Value</li><li class="superclass">Object</li></ul>
<h2>
<a id="defined-in" class="anchor" href="#defined-in">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Defined in:
</h2>
cligen.cr
<br/>
<h2>
<a id="constructors" class="anchor" href="#constructors">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Constructors
</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#new%28short%3AString%2Clong%3AString%2Cdescription%3AString%2Cwork%3AString-%3E%29-class-method" class="signature"><strong>.new</strong>(short : String, long : String, description : String, work : String -> )</a>
</li>
</ul>
<h2>
<a id="instance-method-summary" class="anchor" href="#instance-method-summary">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Instance Method Summary
</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#clone-instance-method" class="signature"><strong>#clone</strong></a>
</li>
<li class="entry-summary">
<a href="#copy_with%28short_short%3D%40short%2Clong_long%3D%40long%2Cdescription_description%3D%40description%2Cwork_work%3D%40work%29-instance-method" class="signature"><strong>#copy_with</strong>(short _short = @short, long _long = @long, description _description = @description, work _work = @work)</a>
</li>
<li class="entry-summary">
<a href="#description%3AString-instance-method" class="signature"><strong>#description</strong> : String</a>
</li>
<li class="entry-summary">
<a href="#long%3AString-instance-method" class="signature"><strong>#long</strong> : String</a>
</li>
<li class="entry-summary">
<a href="#short%3AString-instance-method" class="signature"><strong>#short</strong> : String</a>
</li>
<li class="entry-summary">
<a href="#work%3AString-%3E-instance-method" class="signature"><strong>#work</strong> : String -> </a>
</li>
</ul>
<div class="methods-inherited">
</div>
<h2>
<a id="constructor-detail" class="anchor" href="#constructor-detail">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Constructor Detail
</h2>
<div class="entry-detail" id="new(short:String,long:String,description:String,work:String-&gt;)-class-method">
<div class="signature">
def self.<strong>new</strong>(short : String, long : String, description : String, work : String -> )
<a class="method-permalink" href="#new%28short%3AString%2Clong%3AString%2Cdescription%3AString%2Cwork%3AString-%3E%29-class-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<h2>
<a id="instance-method-detail" class="anchor" href="#instance-method-detail">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Instance Method Detail
</h2>
<div class="entry-detail" id="clone-instance-method">
<div class="signature">
def <strong>clone</strong>
<a class="method-permalink" href="#clone-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="copy_with(short_short=@short,long_long=@long,description_description=@description,work_work=@work)-instance-method">
<div class="signature">
def <strong>copy_with</strong>(short _short = @short, long _long = @long, description _description = @description, work _work = @work)
<a class="method-permalink" href="#copy_with%28short_short%3D%40short%2Clong_long%3D%40long%2Cdescription_description%3D%40description%2Cwork_work%3D%40work%29-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="description:String-instance-method">
<div class="signature">
def <strong>description</strong> : String
<a class="method-permalink" href="#description%3AString-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="long:String-instance-method">
<div class="signature">
def <strong>long</strong> : String
<a class="method-permalink" href="#long%3AString-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="short:String-instance-method">
<div class="signature">
def <strong>short</strong> : String
<a class="method-permalink" href="#short%3AString-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="work:String-&gt;-instance-method">
<div class="signature">
def <strong>work</strong> : String ->
<a class="method-permalink" href="#work%3AString-%3E-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
</div>
</body>
</html>
+451
View File
@@ -0,0 +1,451 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Crystal Docs 1.20.3">
<meta name="crystal_docs.project_version" content="object_rework-dev">
<meta name="crystal_docs.project_name" content="CliGenerator">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<meta name="repository-name" content="CliGenerator">
<title>CliGen::App - CliGenerator object_rework-dev</title>
<script type="text/javascript">
CrystalDocs.base_path = "../";
</script>
</head>
<body>
<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill="currentColor" fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>
<input type="checkbox" id="sidebar-btn">
<label for="sidebar-btn" id="sidebar-btn-label">
<svg class="open" xmlns="http://www.w3.org/2000/svg" height="2em" width="2em" viewBox="0 0 512 512"><title>Open Sidebar</title><path fill="currentColor" d="M80 96v64h352V96H80zm0 112v64h352v-64H80zm0 112v64h352v-64H80z"></path></svg>
<svg class="close" xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" viewBox="0 0 512 512"><title>Close Sidebar</title><path fill="currentColor" d="m118.6 73.4-45.2 45.2L210.7 256 73.4 393.4l45.2 45.2L256 301.3l137.4 137.3 45.2-45.2L301.3 256l137.3-137.4-45.2-45.2L256 210.7Z"></path></svg>
</label>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
<input type="search" class="search-input" placeholder="Search..." spellcheck="false" aria-label="Search">
</div>
<div class="project-summary">
<h1 class="project-name">
<a href="../index.html">
CliGenerator
</a>
</h1>
<span class="project-version">
object_rework-dev
</span>
</div>
</div>
<div class="search-results hidden">
<ul class="search-list"></ul>
</div>
<div class="types-list">
<ul>
<li class="parent open current" data-id="CliGenerator/CliGen" data-name="cligen">
<a href="../CliGen.html">CliGen</a>
<ul>
<li class=" " data-id="CliGenerator/CliGen/AdditionalDefaultFlag" data-name="cligen::additionaldefaultflag">
<a href="../CliGen/AdditionalDefaultFlag.html">AdditionalDefaultFlag</a>
</li>
<li class=" current" data-id="CliGenerator/CliGen/App" data-name="cligen::app">
<a href="../CliGen/App.html">App</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Arg" data-name="cligen::arg">
<a href="../CliGen/Arg.html">Arg</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Argument" data-name="cligen::argument">
<a href="../CliGen/Argument.html">Argument</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/BaseFlag" data-name="cligen::baseflag">
<a href="../CliGen/BaseFlag.html">BaseFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Command" data-name="cligen::command">
<a href="../CliGen/Command.html">Command</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandInfo" data-name="cligen::commandinfo">
<a href="../CliGen/CommandInfo.html">CommandInfo</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandNode" data-name="cligen::commandnode">
<a href="../CliGen/CommandNode.html">CommandNode</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/DefaultFlag" data-name="cligen::defaultflag">
<a href="../CliGen/DefaultFlag.html">DefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Flag" data-name="cligen::flag(t)">
<a href="../CliGen/Flag.html">Flag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Format" data-name="cligen::format">
<a href="../CliGen/Format.html">Format</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/MatchType" data-name="cligen::matchtype">
<a href="../CliGen/MatchType.html">MatchType</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/ProxyCommand" data-name="cligen::proxycommand">
<a href="../CliGen/ProxyCommand.html">ProxyCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Regex" data-name="cligen::regex">
<a href="../CliGen/Regex.html">Regex</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Selection" data-name="cligen::selection">
<a href="../CliGen/Selection.html">Selection</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/SubCommand" data-name="cligen::subcommand">
<a href="../CliGen/SubCommand.html">SubCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Trigger" data-name="cligen::trigger">
<a href="../CliGen/Trigger.html">Trigger</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="main-content">
<h1 class="type-name">
<span class="kind">
class
</span> CliGen::<wbr>App
</h1>
<ul class="superclass-hierarchy"><li class="superclass"><a href="../CliGen/App.html">CliGen::App</a></li><li class="superclass"><a href="../CliGen/CommandNode.html">CliGen::CommandNode</a></li><li class="superclass">Reference</li><li class="superclass">Object</li></ul>
<h2>
<a id="overview" class="anchor" href="#overview">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Overview
</h2>
<p>This serves as the default App object, that holds a copy of all flags &amp;
handles flag processing until it hands off to the user defined commands</p>
<h2>
<a id="defined-in" class="anchor" href="#defined-in">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Defined in:
</h2>
cligen/app.cr
<br/>
<h2>
<a id="constructors" class="anchor" href="#constructors">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Constructors
</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#new%28name%2Cflags%2Ccommands%2Cpre_run_commands%2Cpost_run_commands%29-class-method" class="signature"><strong>.new</strong>(name, flags, commands, pre_run_commands, post_run_commands)</a>
</li>
</ul>
<h2>
<a id="class-method-summary" class="anchor" href="#class-method-summary">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Class Method Summary
</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#process%28args%3AArray%28String%29%3DARGV%29-class-method" class="signature"><strong>.process</strong>(args : Array(String) = <span class="t">ARGV</span>)</a>
<div class="summary"><p>Serves as a convinence method for the user to call to begin processing an argument array provided by the user.</p></div>
</li>
</ul>
<h2>
<a id="instance-method-summary" class="anchor" href="#instance-method-summary">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Instance Method Summary
</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#check%21-instance-method" class="signature"><strong>#check!</strong></a>
</li>
</ul>
<div class="methods-inherited">
<h3>Instance methods inherited from class <code><a href="../CliGen/CommandNode.html">CliGen::CommandNode</a></code></h3>
<a href="../CliGen/CommandNode.html#check%21-instance-method" class="tooltip">
<span>check!</span>
check!</a>,
<a href="../CliGen/CommandNode.html#check_for_duplicates%21%28flags%3AArray%28BaseFlag%29%29-instance-method" class="tooltip">
<span>check_for_duplicates!(flags : Array(BaseFlag))</span>
check_for_duplicates!</a>,
<a href="../CliGen/CommandNode.html#find_match%28arg%3AString%29-instance-method" class="tooltip">
<span>find_match(arg : String)</span>
find_match</a>,
<a href="../CliGen/CommandNode.html#process%28args%3AArray%28String%29%29-instance-method" class="tooltip">
<span>process(args : Array(String))<br/>process(args : Array(Arg)) : Nil</span>
process</a>
<h3>Constructor methods inherited from class <code><a href="../CliGen/CommandNode.html">CliGen::CommandNode</a></code></h3>
<a href="../CliGen/CommandNode.html#new%28name%3AString%2Cflags%3AArray%28CliGen%3A%3ABaseFlag%29%2Ccommands%3AArray%28CliGen%3A%3ACommandNode%29%2Cpre_run_commands%3AArray%28_%29%2Cpost_run_commands%3AArray%28_%29%29-class-method" class="tooltip">
<span>new(name : String, flags : Array(CliGen::BaseFlag), commands : Array(CliGen::CommandNode), pre_run_commands : Array(_), post_run_commands : Array(_))</span>
new</a>
</div>
<h2>
<a id="constructor-detail" class="anchor" href="#constructor-detail">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Constructor Detail
</h2>
<div class="entry-detail" id="new(name,flags,commands,pre_run_commands,post_run_commands)-class-method">
<div class="signature">
def self.<strong>new</strong>(name, flags, commands, pre_run_commands, post_run_commands)
<a class="method-permalink" href="#new%28name%2Cflags%2Ccommands%2Cpre_run_commands%2Cpost_run_commands%29-class-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<h2>
<a id="class-method-detail" class="anchor" href="#class-method-detail">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Class Method Detail
</h2>
<div class="entry-detail" id="process(args:Array(String)=ARGV)-class-method">
<div class="signature">
def self.<strong>process</strong>(args : Array(String) = <span class="t">ARGV</span>)
<a class="method-permalink" href="#process%28args%3AArray%28String%29%3DARGV%29-class-method">#</a>
</div>
<div class="doc">
<p>Serves as a convinence method for the user to call to begin processing an
argument array provided by the user.</p>
<p>This defaults to ARGV for convinence if no arguments are passed through</p>
</div>
<br/>
<div>
</div>
</div>
<h2>
<a id="instance-method-detail" class="anchor" href="#instance-method-detail">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Instance Method Detail
</h2>
<div class="entry-detail" id="check!-instance-method">
<div class="signature">
def <strong>check!</strong>
<a class="method-permalink" href="#check%21-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
</div>
</body>
</html>
+450
View File
@@ -0,0 +1,450 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Crystal Docs 1.20.3">
<meta name="crystal_docs.project_version" content="object_rework-dev">
<meta name="crystal_docs.project_name" content="CliGenerator">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<meta name="repository-name" content="CliGenerator">
<title>CliGen::Arg - CliGenerator object_rework-dev</title>
<script type="text/javascript">
CrystalDocs.base_path = "../";
</script>
</head>
<body>
<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill="currentColor" fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>
<input type="checkbox" id="sidebar-btn">
<label for="sidebar-btn" id="sidebar-btn-label">
<svg class="open" xmlns="http://www.w3.org/2000/svg" height="2em" width="2em" viewBox="0 0 512 512"><title>Open Sidebar</title><path fill="currentColor" d="M80 96v64h352V96H80zm0 112v64h352v-64H80zm0 112v64h352v-64H80z"></path></svg>
<svg class="close" xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" viewBox="0 0 512 512"><title>Close Sidebar</title><path fill="currentColor" d="m118.6 73.4-45.2 45.2L210.7 256 73.4 393.4l45.2 45.2L256 301.3l137.4 137.3 45.2-45.2L301.3 256l137.3-137.4-45.2-45.2L256 210.7Z"></path></svg>
</label>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
<input type="search" class="search-input" placeholder="Search..." spellcheck="false" aria-label="Search">
</div>
<div class="project-summary">
<h1 class="project-name">
<a href="../index.html">
CliGenerator
</a>
</h1>
<span class="project-version">
object_rework-dev
</span>
</div>
</div>
<div class="search-results hidden">
<ul class="search-list"></ul>
</div>
<div class="types-list">
<ul>
<li class="parent open current" data-id="CliGenerator/CliGen" data-name="cligen">
<a href="../CliGen.html">CliGen</a>
<ul>
<li class=" " data-id="CliGenerator/CliGen/AdditionalDefaultFlag" data-name="cligen::additionaldefaultflag">
<a href="../CliGen/AdditionalDefaultFlag.html">AdditionalDefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/App" data-name="cligen::app">
<a href="../CliGen/App.html">App</a>
</li>
<li class=" current" data-id="CliGenerator/CliGen/Arg" data-name="cligen::arg">
<a href="../CliGen/Arg.html">Arg</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Argument" data-name="cligen::argument">
<a href="../CliGen/Argument.html">Argument</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/BaseFlag" data-name="cligen::baseflag">
<a href="../CliGen/BaseFlag.html">BaseFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Command" data-name="cligen::command">
<a href="../CliGen/Command.html">Command</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandInfo" data-name="cligen::commandinfo">
<a href="../CliGen/CommandInfo.html">CommandInfo</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandNode" data-name="cligen::commandnode">
<a href="../CliGen/CommandNode.html">CommandNode</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/DefaultFlag" data-name="cligen::defaultflag">
<a href="../CliGen/DefaultFlag.html">DefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Flag" data-name="cligen::flag(t)">
<a href="../CliGen/Flag.html">Flag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Format" data-name="cligen::format">
<a href="../CliGen/Format.html">Format</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/MatchType" data-name="cligen::matchtype">
<a href="../CliGen/MatchType.html">MatchType</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/ProxyCommand" data-name="cligen::proxycommand">
<a href="../CliGen/ProxyCommand.html">ProxyCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Regex" data-name="cligen::regex">
<a href="../CliGen/Regex.html">Regex</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Selection" data-name="cligen::selection">
<a href="../CliGen/Selection.html">Selection</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/SubCommand" data-name="cligen::subcommand">
<a href="../CliGen/SubCommand.html">SubCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Trigger" data-name="cligen::trigger">
<a href="../CliGen/Trigger.html">Trigger</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="main-content">
<h1 class="type-name">
<span class="kind">
class
</span> CliGen::<wbr>Arg
</h1>
<ul class="superclass-hierarchy"><li class="superclass"><a href="../CliGen/Arg.html">CliGen::Arg</a></li><li class="superclass">Reference</li><li class="superclass">Object</li></ul>
<h2>
<a id="overview" class="anchor" href="#overview">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Overview
</h2>
<p>This class serves as a &quot;argument wrapper&quot; to force a fail-fast approach to
arg-parsing.</p>
<p>It wraps around the argument + index of the argument to do state tracking
and ensure that each argument is only processed once (plus allows for
easier filtering of processed arguments to avoid having to do index math)</p>
<pre><code class="language-crystal">args.reject(<span class="o">&amp;</span>.processed?) <span class="c"># returns the args that haven&#39;t been processed yet</span></code></pre>
<p>It expects each argument to only be processed once and will force a raise
if the argument has Arg#processed called a second time. This is to force
the developer (me) to fix any processing issues during the development of
this framework.</p>
<h2>
<a id="defined-in" class="anchor" href="#defined-in">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Defined in:
</h2>
cligen/arg.cr
<br/>
<h2>
<a id="constructors" class="anchor" href="#constructors">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Constructors
</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#new%28value%3AString%2Cindex%3AInt32%29-class-method" class="signature"><strong>.new</strong>(value : String, index : Int32)</a>
</li>
</ul>
<h2>
<a id="instance-method-summary" class="anchor" href="#instance-method-summary">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Instance Method Summary
</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#index%3AInt32-instance-method" class="signature"><strong>#index</strong> : Int32</a>
<div class="summary"><p>The index of the argument in the array it was in</p></div>
</li>
<li class="entry-summary">
<a href="#processed-instance-method" class="signature"><strong>#processed</strong></a>
<div class="summary"><p>This serves as a trigger that tells the object that it has been processed</p></div>
</li>
<li class="entry-summary">
<a href="#processed%3F%3ABool-instance-method" class="signature"><strong>#processed?</strong> : Bool</a>
<div class="summary"><p>The &quot;flag&quot;/variable that tracks is the Arg has been processed yet</p></div>
</li>
<li class="entry-summary">
<a href="#value%3AString-instance-method" class="signature"><strong>#value</strong> : String</a>
<div class="summary"><p>The raw string argument provided from the user</p></div>
</li>
</ul>
<div class="methods-inherited">
</div>
<h2>
<a id="constructor-detail" class="anchor" href="#constructor-detail">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Constructor Detail
</h2>
<div class="entry-detail" id="new(value:String,index:Int32)-class-method">
<div class="signature">
def self.<strong>new</strong>(value : String, index : Int32)
<a class="method-permalink" href="#new%28value%3AString%2Cindex%3AInt32%29-class-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<h2>
<a id="instance-method-detail" class="anchor" href="#instance-method-detail">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Instance Method Detail
</h2>
<div class="entry-detail" id="index:Int32-instance-method">
<div class="signature">
def <strong>index</strong> : Int32
<a class="method-permalink" href="#index%3AInt32-instance-method">#</a>
</div>
<div class="doc">
<p>The index of the argument in the array it was in</p>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="processed-instance-method">
<div class="signature">
def <strong>processed</strong>
<a class="method-permalink" href="#processed-instance-method">#</a>
</div>
<div class="doc">
<p>This serves as a trigger that tells the object that it has been processed</p>
<p>This will raise an exception if it is re-called after already having been
processed.</p>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="processed?:Bool-instance-method">
<div class="signature">
def <strong>processed?</strong> : Bool
<a class="method-permalink" href="#processed%3F%3ABool-instance-method">#</a>
</div>
<div class="doc">
<p>The &quot;flag&quot;/variable that tracks is the Arg has been processed yet</p>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="value:String-instance-method">
<div class="signature">
def <strong>value</strong> : String
<a class="method-permalink" href="#value%3AString-instance-method">#</a>
</div>
<div class="doc">
<p>The raw string argument provided from the user</p>
</div>
<br/>
<div>
</div>
</div>
</div>
</body>
</html>
+233
View File
@@ -0,0 +1,233 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Crystal Docs 1.20.3">
<meta name="crystal_docs.project_version" content="object_rework-dev">
<meta name="crystal_docs.project_name" content="CliGenerator">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<meta name="repository-name" content="CliGenerator">
<title>CliGen::Argument - CliGenerator object_rework-dev</title>
<script type="text/javascript">
CrystalDocs.base_path = "../";
</script>
</head>
<body>
<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill="currentColor" fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>
<input type="checkbox" id="sidebar-btn">
<label for="sidebar-btn" id="sidebar-btn-label">
<svg class="open" xmlns="http://www.w3.org/2000/svg" height="2em" width="2em" viewBox="0 0 512 512"><title>Open Sidebar</title><path fill="currentColor" d="M80 96v64h352V96H80zm0 112v64h352v-64H80zm0 112v64h352v-64H80z"></path></svg>
<svg class="close" xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" viewBox="0 0 512 512"><title>Close Sidebar</title><path fill="currentColor" d="m118.6 73.4-45.2 45.2L210.7 256 73.4 393.4l45.2 45.2L256 301.3l137.4 137.3 45.2-45.2L301.3 256l137.3-137.4-45.2-45.2L256 210.7Z"></path></svg>
</label>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
<input type="search" class="search-input" placeholder="Search..." spellcheck="false" aria-label="Search">
</div>
<div class="project-summary">
<h1 class="project-name">
<a href="../index.html">
CliGenerator
</a>
</h1>
<span class="project-version">
object_rework-dev
</span>
</div>
</div>
<div class="search-results hidden">
<ul class="search-list"></ul>
</div>
<div class="types-list">
<ul>
<li class="parent open current" data-id="CliGenerator/CliGen" data-name="cligen">
<a href="../CliGen.html">CliGen</a>
<ul>
<li class=" " data-id="CliGenerator/CliGen/AdditionalDefaultFlag" data-name="cligen::additionaldefaultflag">
<a href="../CliGen/AdditionalDefaultFlag.html">AdditionalDefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/App" data-name="cligen::app">
<a href="../CliGen/App.html">App</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Arg" data-name="cligen::arg">
<a href="../CliGen/Arg.html">Arg</a>
</li>
<li class=" current" data-id="CliGenerator/CliGen/Argument" data-name="cligen::argument">
<a href="../CliGen/Argument.html">Argument</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/BaseFlag" data-name="cligen::baseflag">
<a href="../CliGen/BaseFlag.html">BaseFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Command" data-name="cligen::command">
<a href="../CliGen/Command.html">Command</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandInfo" data-name="cligen::commandinfo">
<a href="../CliGen/CommandInfo.html">CommandInfo</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandNode" data-name="cligen::commandnode">
<a href="../CliGen/CommandNode.html">CommandNode</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/DefaultFlag" data-name="cligen::defaultflag">
<a href="../CliGen/DefaultFlag.html">DefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Flag" data-name="cligen::flag(t)">
<a href="../CliGen/Flag.html">Flag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Format" data-name="cligen::format">
<a href="../CliGen/Format.html">Format</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/MatchType" data-name="cligen::matchtype">
<a href="../CliGen/MatchType.html">MatchType</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/ProxyCommand" data-name="cligen::proxycommand">
<a href="../CliGen/ProxyCommand.html">ProxyCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Regex" data-name="cligen::regex">
<a href="../CliGen/Regex.html">Regex</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Selection" data-name="cligen::selection">
<a href="../CliGen/Selection.html">Selection</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/SubCommand" data-name="cligen::subcommand">
<a href="../CliGen/SubCommand.html">SubCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Trigger" data-name="cligen::trigger">
<a href="../CliGen/Trigger.html">Trigger</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="main-content">
<h1 class="type-name">
<span class="kind">
annotation
</span> CliGen::<wbr>Argument
</h1>
<h2>
<a id="defined-in" class="anchor" href="#defined-in">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Defined in:
</h2>
cligen/annotations.cr
<br/>
<div class="methods-inherited">
</div>
</div>
</body>
</html>
+528
View File
@@ -0,0 +1,528 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Crystal Docs 1.20.3">
<meta name="crystal_docs.project_version" content="object_rework-dev">
<meta name="crystal_docs.project_name" content="CliGenerator">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<meta name="repository-name" content="CliGenerator">
<title>CliGen::BaseFlag - CliGenerator object_rework-dev</title>
<script type="text/javascript">
CrystalDocs.base_path = "../";
</script>
</head>
<body>
<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill="currentColor" fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>
<input type="checkbox" id="sidebar-btn">
<label for="sidebar-btn" id="sidebar-btn-label">
<svg class="open" xmlns="http://www.w3.org/2000/svg" height="2em" width="2em" viewBox="0 0 512 512"><title>Open Sidebar</title><path fill="currentColor" d="M80 96v64h352V96H80zm0 112v64h352v-64H80zm0 112v64h352v-64H80z"></path></svg>
<svg class="close" xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" viewBox="0 0 512 512"><title>Close Sidebar</title><path fill="currentColor" d="m118.6 73.4-45.2 45.2L210.7 256 73.4 393.4l45.2 45.2L256 301.3l137.4 137.3 45.2-45.2L301.3 256l137.3-137.4-45.2-45.2L256 210.7Z"></path></svg>
</label>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
<input type="search" class="search-input" placeholder="Search..." spellcheck="false" aria-label="Search">
</div>
<div class="project-summary">
<h1 class="project-name">
<a href="../index.html">
CliGenerator
</a>
</h1>
<span class="project-version">
object_rework-dev
</span>
</div>
</div>
<div class="search-results hidden">
<ul class="search-list"></ul>
</div>
<div class="types-list">
<ul>
<li class="parent open current" data-id="CliGenerator/CliGen" data-name="cligen">
<a href="../CliGen.html">CliGen</a>
<ul>
<li class=" " data-id="CliGenerator/CliGen/AdditionalDefaultFlag" data-name="cligen::additionaldefaultflag">
<a href="../CliGen/AdditionalDefaultFlag.html">AdditionalDefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/App" data-name="cligen::app">
<a href="../CliGen/App.html">App</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Arg" data-name="cligen::arg">
<a href="../CliGen/Arg.html">Arg</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Argument" data-name="cligen::argument">
<a href="../CliGen/Argument.html">Argument</a>
</li>
<li class=" current" data-id="CliGenerator/CliGen/BaseFlag" data-name="cligen::baseflag">
<a href="../CliGen/BaseFlag.html">BaseFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Command" data-name="cligen::command">
<a href="../CliGen/Command.html">Command</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandInfo" data-name="cligen::commandinfo">
<a href="../CliGen/CommandInfo.html">CommandInfo</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandNode" data-name="cligen::commandnode">
<a href="../CliGen/CommandNode.html">CommandNode</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/DefaultFlag" data-name="cligen::defaultflag">
<a href="../CliGen/DefaultFlag.html">DefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Flag" data-name="cligen::flag(t)">
<a href="../CliGen/Flag.html">Flag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Format" data-name="cligen::format">
<a href="../CliGen/Format.html">Format</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/MatchType" data-name="cligen::matchtype">
<a href="../CliGen/MatchType.html">MatchType</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/ProxyCommand" data-name="cligen::proxycommand">
<a href="../CliGen/ProxyCommand.html">ProxyCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Regex" data-name="cligen::regex">
<a href="../CliGen/Regex.html">Regex</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Selection" data-name="cligen::selection">
<a href="../CliGen/Selection.html">Selection</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/SubCommand" data-name="cligen::subcommand">
<a href="../CliGen/SubCommand.html">SubCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Trigger" data-name="cligen::trigger">
<a href="../CliGen/Trigger.html">Trigger</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="main-content">
<h1 class="type-name">
<span class="kind">
abstract class
</span> CliGen::<wbr>BaseFlag
</h1>
<ul class="superclass-hierarchy"><li class="superclass"><a href="../CliGen/BaseFlag.html">CliGen::BaseFlag</a></li><li class="superclass">Reference</li><li class="superclass">Object</li></ul>
<h2>
<a id="direct-known-subclasses" class="anchor" href="#direct-known-subclasses">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Direct Known Subclasses
</h2>
<ul class="other-types-list">
<li class="other-type"><a href="../CliGen/Flag.html">CliGen::Flag(T)</a></li>
</ul>
<h2>
<a id="defined-in" class="anchor" href="#defined-in">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Defined in:
</h2>
cligen/flag.cr
<br/>
<h2>
<a id="constructors" class="anchor" href="#constructors">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Constructors
</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#new%28var%3AString%2Cshort%3AString%7CNil%2Clong%3AString%7CNil%2Cenv_var%3AString%7CNil%2Cdescription%3AString%29-class-method" class="signature"><strong>.new</strong>(var : String, short : String | Nil, long : String | Nil, env_var : String | Nil, description : String)</a>
</li>
</ul>
<h2>
<a id="instance-method-summary" class="anchor" href="#instance-method-summary">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Instance Method Summary
</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#description%3AString-instance-method" class="signature"><strong>#description</strong> : String</a>
</li>
<li class="entry-summary">
<a href="#env_var%3AString%7CNil-instance-method" class="signature"><strong>#env_var</strong> : String | Nil</a>
</li>
<li class="entry-summary">
<a href="#long%3AString%7CNil-instance-method" class="signature"><strong>#long</strong> : String | Nil</a>
</li>
<li class="entry-summary">
<a href="#long_key%3AString-instance-method" class="signature"><strong>#long_key</strong> : String</a>
</li>
<li class="entry-summary">
<a href="#matches%3F%28token%3AString%29%3ABool-instance-method" class="signature"><strong>#matches?</strong>(token : String) : Bool</a>
</li>
<li class="entry-summary">
<a href="#raw_value%3AString%7CNil-instance-method" class="signature"><strong>#raw_value</strong> : String | Nil</a>
</li>
<li class="entry-summary">
<a href="#satisfied%3F%3ABool-instance-method" class="signature"><strong>#satisfied?</strong> : Bool</a>
</li>
<li class="entry-summary">
<a href="#short%3AString%7CNil-instance-method" class="signature"><strong>#short</strong> : String | Nil</a>
</li>
<li class="entry-summary">
<a href="#validate%21%3ANil-instance-method" class="signature"><strong>#validate!</strong> : Nil</a>
</li>
<li class="entry-summary">
<a href="#var%3AString-instance-method" class="signature"><strong>#var</strong> : String</a>
</li>
</ul>
<div class="methods-inherited">
</div>
<h2>
<a id="constructor-detail" class="anchor" href="#constructor-detail">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Constructor Detail
</h2>
<div class="entry-detail" id="new(var:String,short:String|Nil,long:String|Nil,env_var:String|Nil,description:String)-class-method">
<div class="signature">
def self.<strong>new</strong>(var : String, short : String | Nil, long : String | Nil, env_var : String | Nil, description : String)
<a class="method-permalink" href="#new%28var%3AString%2Cshort%3AString%7CNil%2Clong%3AString%7CNil%2Cenv_var%3AString%7CNil%2Cdescription%3AString%29-class-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<h2>
<a id="instance-method-detail" class="anchor" href="#instance-method-detail">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Instance Method Detail
</h2>
<div class="entry-detail" id="description:String-instance-method">
<div class="signature">
def <strong>description</strong> : String
<a class="method-permalink" href="#description%3AString-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="env_var:String|Nil-instance-method">
<div class="signature">
def <strong>env_var</strong> : String | Nil
<a class="method-permalink" href="#env_var%3AString%7CNil-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="long:String|Nil-instance-method">
<div class="signature">
def <strong>long</strong> : String | Nil
<a class="method-permalink" href="#long%3AString%7CNil-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="long_key:String-instance-method">
<div class="signature">
def <strong>long_key</strong> : String
<a class="method-permalink" href="#long_key%3AString-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="matches?(token:String):Bool-instance-method">
<div class="signature">
def <strong>matches?</strong>(token : String) : Bool
<a class="method-permalink" href="#matches%3F%28token%3AString%29%3ABool-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="raw_value:String|Nil-instance-method">
<div class="signature">
abstract
def <strong>raw_value</strong> : String | Nil
<a class="method-permalink" href="#raw_value%3AString%7CNil-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="satisfied?:Bool-instance-method">
<div class="signature">
abstract
def <strong>satisfied?</strong> : Bool
<a class="method-permalink" href="#satisfied%3F%3ABool-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="short:String|Nil-instance-method">
<div class="signature">
def <strong>short</strong> : String | Nil
<a class="method-permalink" href="#short%3AString%7CNil-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="validate!:Nil-instance-method">
<div class="signature">
abstract
def <strong>validate!</strong> : Nil
<a class="method-permalink" href="#validate%21%3ANil-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="var:String-instance-method">
<div class="signature">
def <strong>var</strong> : String
<a class="method-permalink" href="#var%3AString-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
</div>
</body>
</html>
+379
View File
@@ -0,0 +1,379 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Crystal Docs 1.20.3">
<meta name="crystal_docs.project_version" content="object_rework-dev">
<meta name="crystal_docs.project_name" content="CliGenerator">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<meta name="repository-name" content="CliGenerator">
<title>CliGen::Command - CliGenerator object_rework-dev</title>
<script type="text/javascript">
CrystalDocs.base_path = "../";
</script>
</head>
<body>
<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill="currentColor" fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>
<input type="checkbox" id="sidebar-btn">
<label for="sidebar-btn" id="sidebar-btn-label">
<svg class="open" xmlns="http://www.w3.org/2000/svg" height="2em" width="2em" viewBox="0 0 512 512"><title>Open Sidebar</title><path fill="currentColor" d="M80 96v64h352V96H80zm0 112v64h352v-64H80zm0 112v64h352v-64H80z"></path></svg>
<svg class="close" xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" viewBox="0 0 512 512"><title>Close Sidebar</title><path fill="currentColor" d="m118.6 73.4-45.2 45.2L210.7 256 73.4 393.4l45.2 45.2L256 301.3l137.4 137.3 45.2-45.2L301.3 256l137.3-137.4-45.2-45.2L256 210.7Z"></path></svg>
</label>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
<input type="search" class="search-input" placeholder="Search..." spellcheck="false" aria-label="Search">
</div>
<div class="project-summary">
<h1 class="project-name">
<a href="../index.html">
CliGenerator
</a>
</h1>
<span class="project-version">
object_rework-dev
</span>
</div>
</div>
<div class="search-results hidden">
<ul class="search-list"></ul>
</div>
<div class="types-list">
<ul>
<li class="parent open current" data-id="CliGenerator/CliGen" data-name="cligen">
<a href="../CliGen.html">CliGen</a>
<ul>
<li class=" " data-id="CliGenerator/CliGen/AdditionalDefaultFlag" data-name="cligen::additionaldefaultflag">
<a href="../CliGen/AdditionalDefaultFlag.html">AdditionalDefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/App" data-name="cligen::app">
<a href="../CliGen/App.html">App</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Arg" data-name="cligen::arg">
<a href="../CliGen/Arg.html">Arg</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Argument" data-name="cligen::argument">
<a href="../CliGen/Argument.html">Argument</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/BaseFlag" data-name="cligen::baseflag">
<a href="../CliGen/BaseFlag.html">BaseFlag</a>
</li>
<li class=" current" data-id="CliGenerator/CliGen/Command" data-name="cligen::command">
<a href="../CliGen/Command.html">Command</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandInfo" data-name="cligen::commandinfo">
<a href="../CliGen/CommandInfo.html">CommandInfo</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandNode" data-name="cligen::commandnode">
<a href="../CliGen/CommandNode.html">CommandNode</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/DefaultFlag" data-name="cligen::defaultflag">
<a href="../CliGen/DefaultFlag.html">DefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Flag" data-name="cligen::flag(t)">
<a href="../CliGen/Flag.html">Flag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Format" data-name="cligen::format">
<a href="../CliGen/Format.html">Format</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/MatchType" data-name="cligen::matchtype">
<a href="../CliGen/MatchType.html">MatchType</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/ProxyCommand" data-name="cligen::proxycommand">
<a href="../CliGen/ProxyCommand.html">ProxyCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Regex" data-name="cligen::regex">
<a href="../CliGen/Regex.html">Regex</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Selection" data-name="cligen::selection">
<a href="../CliGen/Selection.html">Selection</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/SubCommand" data-name="cligen::subcommand">
<a href="../CliGen/SubCommand.html">SubCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Trigger" data-name="cligen::trigger">
<a href="../CliGen/Trigger.html">Trigger</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="main-content">
<h1 class="type-name">
<span class="kind">
class
</span> CliGen::<wbr>Command
</h1>
<ul class="superclass-hierarchy"><li class="superclass"><a href="../CliGen/Command.html">CliGen::Command</a></li><li class="superclass">Reference</li><li class="superclass">Object</li></ul>
<h2>
<a id="defined-in" class="anchor" href="#defined-in">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Defined in:
</h2>
cligen/command.cr
<br/>
cligen/command/argument.cr
<br/>
cligen/command/selection.cr
<br/>
cligen/command/subcommand.cr
<br/>
cligen/command/trigger.cr
<br/>
<h2>
<a id="macro-summary" class="anchor" href="#macro-summary">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Macro Summary
</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#argument%28variable%2Cshort%2Clong%2Cdescription%2Cvalidation%3Dnil%29-macro" class="signature"><strong>argument</strong>(variable, short, long, description, validation = <span class="n">nil</span>)</a>
</li>
<li class="entry-summary">
<a href="#selection%28variable%2Cshort%2Clong%2Cdescription%2Coptions%29-macro" class="signature"><strong>selection</strong>(variable, short, long, description, options)</a>
</li>
<li class="entry-summary">
<a href="#subcommand%28func%2Cdescription%2Cexamples%3Dnil%2C%26block%29-macro" class="signature"><strong>subcommand</strong>(func, description, examples = <span class="n">nil</span>, &block)</a>
</li>
<li class="entry-summary">
<a href="#trigger%28short%2Clong%2Cargument%3Dnil%2C%26on_match%29-macro" class="signature"><strong>trigger</strong>(short, long, argument = <span class="n">nil</span>, &on_match)</a>
</li>
</ul>
<div class="methods-inherited">
</div>
<h2>
<a id="macro-detail" class="anchor" href="#macro-detail">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Macro Detail
</h2>
<div class="entry-detail" id="argument(variable,short,long,description,validation=nil)-macro">
<div class="signature">
macro <strong>argument</strong>(variable, short, long, description, validation = <span class="n">nil</span>)
<a class="method-permalink" href="#argument%28variable%2Cshort%2Clong%2Cdescription%2Cvalidation%3Dnil%29-macro">#</a>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="selection(variable,short,long,description,options)-macro">
<div class="signature">
macro <strong>selection</strong>(variable, short, long, description, options)
<a class="method-permalink" href="#selection%28variable%2Cshort%2Clong%2Cdescription%2Coptions%29-macro">#</a>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="subcommand(func,description,examples=nil,&amp;block)-macro">
<div class="signature">
macro <strong>subcommand</strong>(func, description, examples = <span class="n">nil</span>, &block)
<a class="method-permalink" href="#subcommand%28func%2Cdescription%2Cexamples%3Dnil%2C%26block%29-macro">#</a>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="trigger(short,long,argument=nil,&amp;on_match)-macro">
<div class="signature">
macro <strong>trigger</strong>(short, long, argument = <span class="n">nil</span>, &on_match)
<a class="method-permalink" href="#trigger%28short%2Clong%2Cargument%3Dnil%2C%26on_match%29-macro">#</a>
</div>
<br/>
<div>
</div>
</div>
</div>
</body>
</html>
+233
View File
@@ -0,0 +1,233 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Crystal Docs 1.20.3">
<meta name="crystal_docs.project_version" content="object_rework-dev">
<meta name="crystal_docs.project_name" content="CliGenerator">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<meta name="repository-name" content="CliGenerator">
<title>CliGen::CommandInfo - CliGenerator object_rework-dev</title>
<script type="text/javascript">
CrystalDocs.base_path = "../";
</script>
</head>
<body>
<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill="currentColor" fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>
<input type="checkbox" id="sidebar-btn">
<label for="sidebar-btn" id="sidebar-btn-label">
<svg class="open" xmlns="http://www.w3.org/2000/svg" height="2em" width="2em" viewBox="0 0 512 512"><title>Open Sidebar</title><path fill="currentColor" d="M80 96v64h352V96H80zm0 112v64h352v-64H80zm0 112v64h352v-64H80z"></path></svg>
<svg class="close" xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" viewBox="0 0 512 512"><title>Close Sidebar</title><path fill="currentColor" d="m118.6 73.4-45.2 45.2L210.7 256 73.4 393.4l45.2 45.2L256 301.3l137.4 137.3 45.2-45.2L301.3 256l137.3-137.4-45.2-45.2L256 210.7Z"></path></svg>
</label>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
<input type="search" class="search-input" placeholder="Search..." spellcheck="false" aria-label="Search">
</div>
<div class="project-summary">
<h1 class="project-name">
<a href="../index.html">
CliGenerator
</a>
</h1>
<span class="project-version">
object_rework-dev
</span>
</div>
</div>
<div class="search-results hidden">
<ul class="search-list"></ul>
</div>
<div class="types-list">
<ul>
<li class="parent open current" data-id="CliGenerator/CliGen" data-name="cligen">
<a href="../CliGen.html">CliGen</a>
<ul>
<li class=" " data-id="CliGenerator/CliGen/AdditionalDefaultFlag" data-name="cligen::additionaldefaultflag">
<a href="../CliGen/AdditionalDefaultFlag.html">AdditionalDefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/App" data-name="cligen::app">
<a href="../CliGen/App.html">App</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Arg" data-name="cligen::arg">
<a href="../CliGen/Arg.html">Arg</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Argument" data-name="cligen::argument">
<a href="../CliGen/Argument.html">Argument</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/BaseFlag" data-name="cligen::baseflag">
<a href="../CliGen/BaseFlag.html">BaseFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Command" data-name="cligen::command">
<a href="../CliGen/Command.html">Command</a>
</li>
<li class=" current" data-id="CliGenerator/CliGen/CommandInfo" data-name="cligen::commandinfo">
<a href="../CliGen/CommandInfo.html">CommandInfo</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandNode" data-name="cligen::commandnode">
<a href="../CliGen/CommandNode.html">CommandNode</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/DefaultFlag" data-name="cligen::defaultflag">
<a href="../CliGen/DefaultFlag.html">DefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Flag" data-name="cligen::flag(t)">
<a href="../CliGen/Flag.html">Flag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Format" data-name="cligen::format">
<a href="../CliGen/Format.html">Format</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/MatchType" data-name="cligen::matchtype">
<a href="../CliGen/MatchType.html">MatchType</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/ProxyCommand" data-name="cligen::proxycommand">
<a href="../CliGen/ProxyCommand.html">ProxyCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Regex" data-name="cligen::regex">
<a href="../CliGen/Regex.html">Regex</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Selection" data-name="cligen::selection">
<a href="../CliGen/Selection.html">Selection</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/SubCommand" data-name="cligen::subcommand">
<a href="../CliGen/SubCommand.html">SubCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Trigger" data-name="cligen::trigger">
<a href="../CliGen/Trigger.html">Trigger</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="main-content">
<h1 class="type-name">
<span class="kind">
annotation
</span> CliGen::<wbr>CommandInfo
</h1>
<h2>
<a id="defined-in" class="anchor" href="#defined-in">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Defined in:
</h2>
cligen/annotations.cr
<br/>
<div class="methods-inherited">
</div>
</div>
</body>
</html>
+441
View File
@@ -0,0 +1,441 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Crystal Docs 1.20.3">
<meta name="crystal_docs.project_version" content="object_rework-dev">
<meta name="crystal_docs.project_name" content="CliGenerator">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<meta name="repository-name" content="CliGenerator">
<title>CliGen::CommandNode - CliGenerator object_rework-dev</title>
<script type="text/javascript">
CrystalDocs.base_path = "../";
</script>
</head>
<body>
<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill="currentColor" fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>
<input type="checkbox" id="sidebar-btn">
<label for="sidebar-btn" id="sidebar-btn-label">
<svg class="open" xmlns="http://www.w3.org/2000/svg" height="2em" width="2em" viewBox="0 0 512 512"><title>Open Sidebar</title><path fill="currentColor" d="M80 96v64h352V96H80zm0 112v64h352v-64H80zm0 112v64h352v-64H80z"></path></svg>
<svg class="close" xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" viewBox="0 0 512 512"><title>Close Sidebar</title><path fill="currentColor" d="m118.6 73.4-45.2 45.2L210.7 256 73.4 393.4l45.2 45.2L256 301.3l137.4 137.3 45.2-45.2L301.3 256l137.3-137.4-45.2-45.2L256 210.7Z"></path></svg>
</label>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
<input type="search" class="search-input" placeholder="Search..." spellcheck="false" aria-label="Search">
</div>
<div class="project-summary">
<h1 class="project-name">
<a href="../index.html">
CliGenerator
</a>
</h1>
<span class="project-version">
object_rework-dev
</span>
</div>
</div>
<div class="search-results hidden">
<ul class="search-list"></ul>
</div>
<div class="types-list">
<ul>
<li class="parent open current" data-id="CliGenerator/CliGen" data-name="cligen">
<a href="../CliGen.html">CliGen</a>
<ul>
<li class=" " data-id="CliGenerator/CliGen/AdditionalDefaultFlag" data-name="cligen::additionaldefaultflag">
<a href="../CliGen/AdditionalDefaultFlag.html">AdditionalDefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/App" data-name="cligen::app">
<a href="../CliGen/App.html">App</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Arg" data-name="cligen::arg">
<a href="../CliGen/Arg.html">Arg</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Argument" data-name="cligen::argument">
<a href="../CliGen/Argument.html">Argument</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/BaseFlag" data-name="cligen::baseflag">
<a href="../CliGen/BaseFlag.html">BaseFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Command" data-name="cligen::command">
<a href="../CliGen/Command.html">Command</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandInfo" data-name="cligen::commandinfo">
<a href="../CliGen/CommandInfo.html">CommandInfo</a>
</li>
<li class=" current" data-id="CliGenerator/CliGen/CommandNode" data-name="cligen::commandnode">
<a href="../CliGen/CommandNode.html">CommandNode</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/DefaultFlag" data-name="cligen::defaultflag">
<a href="../CliGen/DefaultFlag.html">DefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Flag" data-name="cligen::flag(t)">
<a href="../CliGen/Flag.html">Flag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Format" data-name="cligen::format">
<a href="../CliGen/Format.html">Format</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/MatchType" data-name="cligen::matchtype">
<a href="../CliGen/MatchType.html">MatchType</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/ProxyCommand" data-name="cligen::proxycommand">
<a href="../CliGen/ProxyCommand.html">ProxyCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Regex" data-name="cligen::regex">
<a href="../CliGen/Regex.html">Regex</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Selection" data-name="cligen::selection">
<a href="../CliGen/Selection.html">Selection</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/SubCommand" data-name="cligen::subcommand">
<a href="../CliGen/SubCommand.html">SubCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Trigger" data-name="cligen::trigger">
<a href="../CliGen/Trigger.html">Trigger</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="main-content">
<h1 class="type-name">
<span class="kind">
class
</span> CliGen::<wbr>CommandNode
</h1>
<ul class="superclass-hierarchy"><li class="superclass"><a href="../CliGen/CommandNode.html">CliGen::CommandNode</a></li><li class="superclass">Reference</li><li class="superclass">Object</li></ul>
<h2>
<a id="direct-known-subclasses" class="anchor" href="#direct-known-subclasses">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Direct Known Subclasses
</h2>
<ul class="other-types-list">
<li class="other-type"><a href="../CliGen/App.html">CliGen::App</a></li>
</ul>
<h2>
<a id="defined-in" class="anchor" href="#defined-in">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Defined in:
</h2>
cligen/command_node.cr
<br/>
<h2>
<a id="constructors" class="anchor" href="#constructors">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Constructors
</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#new%28name%3AString%2Cflags%3AArray%28CliGen%3A%3ABaseFlag%29%2Ccommands%3AArray%28CliGen%3A%3ACommandNode%29%2Cpre_run_commands%3AArray%28_%29%2Cpost_run_commands%3AArray%28_%29%29-class-method" class="signature"><strong>.new</strong>(name : String, flags : Array(CliGen::BaseFlag), commands : Array(CliGen::CommandNode), pre_run_commands : Array(_), post_run_commands : Array(_))</a>
</li>
</ul>
<h2>
<a id="instance-method-summary" class="anchor" href="#instance-method-summary">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Instance Method Summary
</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#check%21-instance-method" class="signature"><strong>#check!</strong></a>
</li>
<li class="entry-summary">
<a href="#check_for_duplicates%21%28flags%3AArray%28BaseFlag%29%29-instance-method" class="signature"><strong>#check_for_duplicates!</strong>(flags : Array(BaseFlag))</a>
</li>
<li class="entry-summary">
<a href="#find_match%28arg%3AString%29-instance-method" class="signature"><strong>#find_match</strong>(arg : String)</a>
</li>
<li class="entry-summary">
<a href="#process%28args%3AArray%28String%29%29-instance-method" class="signature"><strong>#process</strong>(args : Array(String))</a>
<div class="summary"><p>This serves to just convert the arguments into a usable Array(Arg) format and pass it to the ACTUAL CommandNode#process method</p></div>
</li>
<li class="entry-summary">
<a href="#process%28args%3AArray%28Arg%29%29%3ANil-instance-method" class="signature"><strong>#process</strong>(args : Array(Arg)) : Nil</a>
</li>
</ul>
<div class="methods-inherited">
</div>
<h2>
<a id="constructor-detail" class="anchor" href="#constructor-detail">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Constructor Detail
</h2>
<div class="entry-detail" id="new(name:String,flags:Array(CliGen::BaseFlag),commands:Array(CliGen::CommandNode),pre_run_commands:Array(_),post_run_commands:Array(_))-class-method">
<div class="signature">
def self.<strong>new</strong>(name : String, flags : Array(<a href="../CliGen/BaseFlag.html">CliGen::BaseFlag</a>), commands : Array(<a href="../CliGen/CommandNode.html">CliGen::CommandNode</a>), pre_run_commands : Array(_), post_run_commands : Array(_))
<a class="method-permalink" href="#new%28name%3AString%2Cflags%3AArray%28CliGen%3A%3ABaseFlag%29%2Ccommands%3AArray%28CliGen%3A%3ACommandNode%29%2Cpre_run_commands%3AArray%28_%29%2Cpost_run_commands%3AArray%28_%29%29-class-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<h2>
<a id="instance-method-detail" class="anchor" href="#instance-method-detail">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Instance Method Detail
</h2>
<div class="entry-detail" id="check!-instance-method">
<div class="signature">
def <strong>check!</strong>
<a class="method-permalink" href="#check%21-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="check_for_duplicates!(flags:Array(BaseFlag))-instance-method">
<div class="signature">
def <strong>check_for_duplicates!</strong>(flags : Array(<a href="../CliGen/BaseFlag.html">BaseFlag</a>))
<a class="method-permalink" href="#check_for_duplicates%21%28flags%3AArray%28BaseFlag%29%29-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="find_match(arg:String)-instance-method">
<div class="signature">
def <strong>find_match</strong>(arg : String)
<a class="method-permalink" href="#find_match%28arg%3AString%29-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="process(args:Array(String))-instance-method">
<div class="signature">
def <strong>process</strong>(args : Array(String))
<a class="method-permalink" href="#process%28args%3AArray%28String%29%29-instance-method">#</a>
</div>
<div class="doc">
<p>This serves to just convert the arguments into a usable Array(Arg) format
and pass it to the ACTUAL CommandNode#process method</p>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="process(args:Array(Arg)):Nil-instance-method">
<div class="signature">
def <strong>process</strong>(args : Array(<a href="../CliGen/Arg.html">Arg</a>)) : Nil
<a class="method-permalink" href="#process%28args%3AArray%28Arg%29%29%3ANil-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
</div>
</body>
</html>
+233
View File
@@ -0,0 +1,233 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Crystal Docs 1.20.3">
<meta name="crystal_docs.project_version" content="object_rework-dev">
<meta name="crystal_docs.project_name" content="CliGenerator">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<meta name="repository-name" content="CliGenerator">
<title>CliGen::DefaultFlag - CliGenerator object_rework-dev</title>
<script type="text/javascript">
CrystalDocs.base_path = "../";
</script>
</head>
<body>
<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill="currentColor" fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>
<input type="checkbox" id="sidebar-btn">
<label for="sidebar-btn" id="sidebar-btn-label">
<svg class="open" xmlns="http://www.w3.org/2000/svg" height="2em" width="2em" viewBox="0 0 512 512"><title>Open Sidebar</title><path fill="currentColor" d="M80 96v64h352V96H80zm0 112v64h352v-64H80zm0 112v64h352v-64H80z"></path></svg>
<svg class="close" xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" viewBox="0 0 512 512"><title>Close Sidebar</title><path fill="currentColor" d="m118.6 73.4-45.2 45.2L210.7 256 73.4 393.4l45.2 45.2L256 301.3l137.4 137.3 45.2-45.2L301.3 256l137.3-137.4-45.2-45.2L256 210.7Z"></path></svg>
</label>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
<input type="search" class="search-input" placeholder="Search..." spellcheck="false" aria-label="Search">
</div>
<div class="project-summary">
<h1 class="project-name">
<a href="../index.html">
CliGenerator
</a>
</h1>
<span class="project-version">
object_rework-dev
</span>
</div>
</div>
<div class="search-results hidden">
<ul class="search-list"></ul>
</div>
<div class="types-list">
<ul>
<li class="parent open current" data-id="CliGenerator/CliGen" data-name="cligen">
<a href="../CliGen.html">CliGen</a>
<ul>
<li class=" " data-id="CliGenerator/CliGen/AdditionalDefaultFlag" data-name="cligen::additionaldefaultflag">
<a href="../CliGen/AdditionalDefaultFlag.html">AdditionalDefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/App" data-name="cligen::app">
<a href="../CliGen/App.html">App</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Arg" data-name="cligen::arg">
<a href="../CliGen/Arg.html">Arg</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Argument" data-name="cligen::argument">
<a href="../CliGen/Argument.html">Argument</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/BaseFlag" data-name="cligen::baseflag">
<a href="../CliGen/BaseFlag.html">BaseFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Command" data-name="cligen::command">
<a href="../CliGen/Command.html">Command</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandInfo" data-name="cligen::commandinfo">
<a href="../CliGen/CommandInfo.html">CommandInfo</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandNode" data-name="cligen::commandnode">
<a href="../CliGen/CommandNode.html">CommandNode</a>
</li>
<li class=" current" data-id="CliGenerator/CliGen/DefaultFlag" data-name="cligen::defaultflag">
<a href="../CliGen/DefaultFlag.html">DefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Flag" data-name="cligen::flag(t)">
<a href="../CliGen/Flag.html">Flag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Format" data-name="cligen::format">
<a href="../CliGen/Format.html">Format</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/MatchType" data-name="cligen::matchtype">
<a href="../CliGen/MatchType.html">MatchType</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/ProxyCommand" data-name="cligen::proxycommand">
<a href="../CliGen/ProxyCommand.html">ProxyCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Regex" data-name="cligen::regex">
<a href="../CliGen/Regex.html">Regex</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Selection" data-name="cligen::selection">
<a href="../CliGen/Selection.html">Selection</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/SubCommand" data-name="cligen::subcommand">
<a href="../CliGen/SubCommand.html">SubCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Trigger" data-name="cligen::trigger">
<a href="../CliGen/Trigger.html">Trigger</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="main-content">
<h1 class="type-name">
<span class="kind">
annotation
</span> CliGen::<wbr>DefaultFlag
</h1>
<h2>
<a id="defined-in" class="anchor" href="#defined-in">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Defined in:
</h2>
cligen.cr
<br/>
<div class="methods-inherited">
</div>
</div>
</body>
</html>
+514
View File
@@ -0,0 +1,514 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Crystal Docs 1.20.3">
<meta name="crystal_docs.project_version" content="object_rework-dev">
<meta name="crystal_docs.project_name" content="CliGenerator">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<meta name="repository-name" content="CliGenerator">
<title>CliGen::Flag(T) - CliGenerator object_rework-dev</title>
<script type="text/javascript">
CrystalDocs.base_path = "../";
</script>
</head>
<body>
<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill="currentColor" fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>
<input type="checkbox" id="sidebar-btn">
<label for="sidebar-btn" id="sidebar-btn-label">
<svg class="open" xmlns="http://www.w3.org/2000/svg" height="2em" width="2em" viewBox="0 0 512 512"><title>Open Sidebar</title><path fill="currentColor" d="M80 96v64h352V96H80zm0 112v64h352v-64H80zm0 112v64h352v-64H80z"></path></svg>
<svg class="close" xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" viewBox="0 0 512 512"><title>Close Sidebar</title><path fill="currentColor" d="m118.6 73.4-45.2 45.2L210.7 256 73.4 393.4l45.2 45.2L256 301.3l137.4 137.3 45.2-45.2L301.3 256l137.3-137.4-45.2-45.2L256 210.7Z"></path></svg>
</label>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
<input type="search" class="search-input" placeholder="Search..." spellcheck="false" aria-label="Search">
</div>
<div class="project-summary">
<h1 class="project-name">
<a href="../index.html">
CliGenerator
</a>
</h1>
<span class="project-version">
object_rework-dev
</span>
</div>
</div>
<div class="search-results hidden">
<ul class="search-list"></ul>
</div>
<div class="types-list">
<ul>
<li class="parent open current" data-id="CliGenerator/CliGen" data-name="cligen">
<a href="../CliGen.html">CliGen</a>
<ul>
<li class=" " data-id="CliGenerator/CliGen/AdditionalDefaultFlag" data-name="cligen::additionaldefaultflag">
<a href="../CliGen/AdditionalDefaultFlag.html">AdditionalDefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/App" data-name="cligen::app">
<a href="../CliGen/App.html">App</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Arg" data-name="cligen::arg">
<a href="../CliGen/Arg.html">Arg</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Argument" data-name="cligen::argument">
<a href="../CliGen/Argument.html">Argument</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/BaseFlag" data-name="cligen::baseflag">
<a href="../CliGen/BaseFlag.html">BaseFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Command" data-name="cligen::command">
<a href="../CliGen/Command.html">Command</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandInfo" data-name="cligen::commandinfo">
<a href="../CliGen/CommandInfo.html">CommandInfo</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandNode" data-name="cligen::commandnode">
<a href="../CliGen/CommandNode.html">CommandNode</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/DefaultFlag" data-name="cligen::defaultflag">
<a href="../CliGen/DefaultFlag.html">DefaultFlag</a>
</li>
<li class=" current" data-id="CliGenerator/CliGen/Flag" data-name="cligen::flag(t)">
<a href="../CliGen/Flag.html">Flag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Format" data-name="cligen::format">
<a href="../CliGen/Format.html">Format</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/MatchType" data-name="cligen::matchtype">
<a href="../CliGen/MatchType.html">MatchType</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/ProxyCommand" data-name="cligen::proxycommand">
<a href="../CliGen/ProxyCommand.html">ProxyCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Regex" data-name="cligen::regex">
<a href="../CliGen/Regex.html">Regex</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Selection" data-name="cligen::selection">
<a href="../CliGen/Selection.html">Selection</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/SubCommand" data-name="cligen::subcommand">
<a href="../CliGen/SubCommand.html">SubCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Trigger" data-name="cligen::trigger">
<a href="../CliGen/Trigger.html">Trigger</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="main-content">
<h1 class="type-name">
<span class="kind">
class
</span> CliGen::<wbr>Flag(T)
</h1>
<ul class="superclass-hierarchy"><li class="superclass"><a href="../CliGen/Flag.html">CliGen::Flag(T)</a></li><li class="superclass"><a href="../CliGen/BaseFlag.html">CliGen::BaseFlag</a></li><li class="superclass">Reference</li><li class="superclass">Object</li></ul>
<h2>
<a id="defined-in" class="anchor" href="#defined-in">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Defined in:
</h2>
cligen/flag.cr
<br/>
<h2>
<a id="constructors" class="anchor" href="#constructors">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Constructors
</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#new%28var%3AString%2Cshort%3AString%7CNil%2Clong%3AString%7CNil%2Cenv_var%3AString%7CNil%2Cdescription%3AString%2Cdefault%3AT%7CNil%3Dnil%2Coptions%3AArray%28String%29%7CNil%3Dnil%2Cvalidate%3AT-%3EBool%7CNil%3Dnil%2Con_match%3AProc%28Nil%29%7CNil%3Dnil%29-class-method" class="signature"><strong>.new</strong>(var : String, short : String | Nil, long : String | Nil, env_var : String | Nil, description : String, default : T | Nil = <span class="n">nil</span>, options : Array(String) | Nil = <span class="n">nil</span>, validate : T -> Bool | Nil = <span class="n">nil</span>, on_match : Proc(Nil) | Nil = <span class="n">nil</span>)</a>
</li>
</ul>
<h2>
<a id="instance-method-summary" class="anchor" href="#instance-method-summary">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Instance Method Summary
</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#process%28argv%3AArray%28Arg%29%3D%5B%5DofArray%28Arg%29%29%3ANil-instance-method" class="signature"><strong>#process</strong>(argv : Array(Arg) = <span class="o">[]</span> <span class="k">of</span> <span class="t">Array</span>(<span class="t">Arg</span>)) : Nil</a>
</li>
<li class="entry-summary">
<a href="#raw_value%3AString%7CNil-instance-method" class="signature"><strong>#raw_value</strong> : String | Nil</a>
</li>
<li class="entry-summary">
<a href="#requires_arg%3F%3ABool-instance-method" class="signature"><strong>#requires_arg?</strong> : Bool</a>
</li>
<li class="entry-summary">
<a href="#satisfied%3F%3ABool-instance-method" class="signature"><strong>#satisfied?</strong> : Bool</a>
</li>
<li class="entry-summary">
<a href="#validate%21%3ANil-instance-method" class="signature"><strong>#validate!</strong> : Nil</a>
</li>
<li class="entry-summary">
<a href="#value%21%3AT-instance-method" class="signature"><strong>#value!</strong> : T</a>
</li>
</ul>
<div class="methods-inherited">
<h3>Instance methods inherited from class <code><a href="../CliGen/BaseFlag.html">CliGen::BaseFlag</a></code></h3>
<a href="../CliGen/BaseFlag.html#description%3AString-instance-method" class="tooltip">
<span>description : String</span>
description</a>,
<a href="../CliGen/BaseFlag.html#env_var%3AString%7CNil-instance-method" class="tooltip">
<span>env_var : String | Nil</span>
env_var</a>,
<a href="../CliGen/BaseFlag.html#long%3AString%7CNil-instance-method" class="tooltip">
<span>long : String | Nil</span>
long</a>,
<a href="../CliGen/BaseFlag.html#long_key%3AString-instance-method" class="tooltip">
<span>long_key : String</span>
long_key</a>,
<a href="../CliGen/BaseFlag.html#matches%3F%28token%3AString%29%3ABool-instance-method" class="tooltip">
<span>matches?(token : String) : Bool</span>
matches?</a>,
<a href="../CliGen/BaseFlag.html#raw_value%3AString%7CNil-instance-method" class="tooltip">
<span>raw_value : String | Nil</span>
raw_value</a>,
<a href="../CliGen/BaseFlag.html#satisfied%3F%3ABool-instance-method" class="tooltip">
<span>satisfied? : Bool</span>
satisfied?</a>,
<a href="../CliGen/BaseFlag.html#short%3AString%7CNil-instance-method" class="tooltip">
<span>short : String | Nil</span>
short</a>,
<a href="../CliGen/BaseFlag.html#validate%21%3ANil-instance-method" class="tooltip">
<span>validate! : Nil</span>
validate!</a>,
<a href="../CliGen/BaseFlag.html#var%3AString-instance-method" class="tooltip">
<span>var : String</span>
var</a>
<h3>Constructor methods inherited from class <code><a href="../CliGen/BaseFlag.html">CliGen::BaseFlag</a></code></h3>
<a href="../CliGen/BaseFlag.html#new%28var%3AString%2Cshort%3AString%7CNil%2Clong%3AString%7CNil%2Cenv_var%3AString%7CNil%2Cdescription%3AString%29-class-method" class="tooltip">
<span>new(var : String, short : String | Nil, long : String | Nil, env_var : String | Nil, description : String)</span>
new</a>
</div>
<h2>
<a id="constructor-detail" class="anchor" href="#constructor-detail">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Constructor Detail
</h2>
<div class="entry-detail" id="new(var:String,short:String|Nil,long:String|Nil,env_var:String|Nil,description:String,default:T|Nil=nil,options:Array(String)|Nil=nil,validate:T-&gt;Bool|Nil=nil,on_match:Proc(Nil)|Nil=nil)-class-method">
<div class="signature">
def self.<strong>new</strong>(var : String, short : String | Nil, long : String | Nil, env_var : String | Nil, description : String, default : T | Nil = <span class="n">nil</span>, options : Array(String) | Nil = <span class="n">nil</span>, validate : T -> Bool | Nil = <span class="n">nil</span>, on_match : Proc(Nil) | Nil = <span class="n">nil</span>)
<a class="method-permalink" href="#new%28var%3AString%2Cshort%3AString%7CNil%2Clong%3AString%7CNil%2Cenv_var%3AString%7CNil%2Cdescription%3AString%2Cdefault%3AT%7CNil%3Dnil%2Coptions%3AArray%28String%29%7CNil%3Dnil%2Cvalidate%3AT-%3EBool%7CNil%3Dnil%2Con_match%3AProc%28Nil%29%7CNil%3Dnil%29-class-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<h2>
<a id="instance-method-detail" class="anchor" href="#instance-method-detail">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Instance Method Detail
</h2>
<div class="entry-detail" id="process(argv:Array(Arg)=[]ofArray(Arg)):Nil-instance-method">
<div class="signature">
def <strong>process</strong>(argv : Array(<a href="../CliGen/Arg.html">Arg</a>) = <span class="o">[]</span> <span class="k">of</span> <span class="t">Array</span>(<span class="t">Arg</span>)) : Nil
<a class="method-permalink" href="#process%28argv%3AArray%28Arg%29%3D%5B%5DofArray%28Arg%29%29%3ANil-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="raw_value:String|Nil-instance-method">
<div class="signature">
def <strong>raw_value</strong> : String | Nil
<a class="method-permalink" href="#raw_value%3AString%7CNil-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="requires_arg?:Bool-instance-method">
<div class="signature">
def <strong>requires_arg?</strong> : Bool
<a class="method-permalink" href="#requires_arg%3F%3ABool-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="satisfied?:Bool-instance-method">
<div class="signature">
def <strong>satisfied?</strong> : Bool
<a class="method-permalink" href="#satisfied%3F%3ABool-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="validate!:Nil-instance-method">
<div class="signature">
def <strong>validate!</strong> : Nil
<a class="method-permalink" href="#validate%21%3ANil-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="value!:T-instance-method">
<div class="signature">
def <strong>value!</strong> : T
<a class="method-permalink" href="#value%21%3AT-instance-method">#</a>
</div>
<br/>
<div>
</div>
</div>
</div>
</body>
</html>
+257
View File
@@ -0,0 +1,257 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Crystal Docs 1.20.3">
<meta name="crystal_docs.project_version" content="object_rework-dev">
<meta name="crystal_docs.project_name" content="CliGenerator">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<meta name="repository-name" content="CliGenerator">
<title>CliGen::Format - CliGenerator object_rework-dev</title>
<script type="text/javascript">
CrystalDocs.base_path = "../";
</script>
</head>
<body>
<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill="currentColor" fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>
<input type="checkbox" id="sidebar-btn">
<label for="sidebar-btn" id="sidebar-btn-label">
<svg class="open" xmlns="http://www.w3.org/2000/svg" height="2em" width="2em" viewBox="0 0 512 512"><title>Open Sidebar</title><path fill="currentColor" d="M80 96v64h352V96H80zm0 112v64h352v-64H80zm0 112v64h352v-64H80z"></path></svg>
<svg class="close" xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" viewBox="0 0 512 512"><title>Close Sidebar</title><path fill="currentColor" d="m118.6 73.4-45.2 45.2L210.7 256 73.4 393.4l45.2 45.2L256 301.3l137.4 137.3 45.2-45.2L301.3 256l137.3-137.4-45.2-45.2L256 210.7Z"></path></svg>
</label>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
<input type="search" class="search-input" placeholder="Search..." spellcheck="false" aria-label="Search">
</div>
<div class="project-summary">
<h1 class="project-name">
<a href="../index.html">
CliGenerator
</a>
</h1>
<span class="project-version">
object_rework-dev
</span>
</div>
</div>
<div class="search-results hidden">
<ul class="search-list"></ul>
</div>
<div class="types-list">
<ul>
<li class="parent open current" data-id="CliGenerator/CliGen" data-name="cligen">
<a href="../CliGen.html">CliGen</a>
<ul>
<li class=" " data-id="CliGenerator/CliGen/AdditionalDefaultFlag" data-name="cligen::additionaldefaultflag">
<a href="../CliGen/AdditionalDefaultFlag.html">AdditionalDefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/App" data-name="cligen::app">
<a href="../CliGen/App.html">App</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Arg" data-name="cligen::arg">
<a href="../CliGen/Arg.html">Arg</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Argument" data-name="cligen::argument">
<a href="../CliGen/Argument.html">Argument</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/BaseFlag" data-name="cligen::baseflag">
<a href="../CliGen/BaseFlag.html">BaseFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Command" data-name="cligen::command">
<a href="../CliGen/Command.html">Command</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandInfo" data-name="cligen::commandinfo">
<a href="../CliGen/CommandInfo.html">CommandInfo</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandNode" data-name="cligen::commandnode">
<a href="../CliGen/CommandNode.html">CommandNode</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/DefaultFlag" data-name="cligen::defaultflag">
<a href="../CliGen/DefaultFlag.html">DefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Flag" data-name="cligen::flag(t)">
<a href="../CliGen/Flag.html">Flag</a>
</li>
<li class=" current" data-id="CliGenerator/CliGen/Format" data-name="cligen::format">
<a href="../CliGen/Format.html">Format</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/MatchType" data-name="cligen::matchtype">
<a href="../CliGen/MatchType.html">MatchType</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/ProxyCommand" data-name="cligen::proxycommand">
<a href="../CliGen/ProxyCommand.html">ProxyCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Regex" data-name="cligen::regex">
<a href="../CliGen/Regex.html">Regex</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Selection" data-name="cligen::selection">
<a href="../CliGen/Selection.html">Selection</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/SubCommand" data-name="cligen::subcommand">
<a href="../CliGen/SubCommand.html">SubCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Trigger" data-name="cligen::trigger">
<a href="../CliGen/Trigger.html">Trigger</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="main-content">
<h1 class="type-name">
<span class="kind">
module
</span> CliGen::<wbr>Format
</h1>
<h2>
<a id="defined-in" class="anchor" href="#defined-in">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Defined in:
</h2>
cligen/format.cr
<br/>
<h2>
<a id="constant-summary" class="anchor" href="#constant-summary">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Constant Summary
</h2>
<dl>
<dt class="entry-const" id="INPUT_DATE_FORMAT">
<strong>INPUT_DATE_FORMAT</strong> = <code><span class="s">&quot;%Y-%m-%d&quot;</span></code>
</dt>
<dt class="entry-const" id="INPUT_DATETIME_FORMAT">
<strong>INPUT_DATETIME_FORMAT</strong> = <code><span class="s">&quot;%Y-%m-%d %H:%M:%S&quot;</span></code>
</dt>
</dl>
<div class="methods-inherited">
</div>
</div>
</body>
</html>
+445
View File
@@ -0,0 +1,445 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Crystal Docs 1.20.3">
<meta name="crystal_docs.project_version" content="object_rework-dev">
<meta name="crystal_docs.project_name" content="CliGenerator">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<meta name="repository-name" content="CliGenerator">
<title>CliGen::MatchType - CliGenerator object_rework-dev</title>
<script type="text/javascript">
CrystalDocs.base_path = "../";
</script>
</head>
<body>
<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill="currentColor" fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>
<input type="checkbox" id="sidebar-btn">
<label for="sidebar-btn" id="sidebar-btn-label">
<svg class="open" xmlns="http://www.w3.org/2000/svg" height="2em" width="2em" viewBox="0 0 512 512"><title>Open Sidebar</title><path fill="currentColor" d="M80 96v64h352V96H80zm0 112v64h352v-64H80zm0 112v64h352v-64H80z"></path></svg>
<svg class="close" xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" viewBox="0 0 512 512"><title>Close Sidebar</title><path fill="currentColor" d="m118.6 73.4-45.2 45.2L210.7 256 73.4 393.4l45.2 45.2L256 301.3l137.4 137.3 45.2-45.2L301.3 256l137.3-137.4-45.2-45.2L256 210.7Z"></path></svg>
</label>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
<input type="search" class="search-input" placeholder="Search..." spellcheck="false" aria-label="Search">
</div>
<div class="project-summary">
<h1 class="project-name">
<a href="../index.html">
CliGenerator
</a>
</h1>
<span class="project-version">
object_rework-dev
</span>
</div>
</div>
<div class="search-results hidden">
<ul class="search-list"></ul>
</div>
<div class="types-list">
<ul>
<li class="parent open current" data-id="CliGenerator/CliGen" data-name="cligen">
<a href="../CliGen.html">CliGen</a>
<ul>
<li class=" " data-id="CliGenerator/CliGen/AdditionalDefaultFlag" data-name="cligen::additionaldefaultflag">
<a href="../CliGen/AdditionalDefaultFlag.html">AdditionalDefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/App" data-name="cligen::app">
<a href="../CliGen/App.html">App</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Arg" data-name="cligen::arg">
<a href="../CliGen/Arg.html">Arg</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Argument" data-name="cligen::argument">
<a href="../CliGen/Argument.html">Argument</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/BaseFlag" data-name="cligen::baseflag">
<a href="../CliGen/BaseFlag.html">BaseFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Command" data-name="cligen::command">
<a href="../CliGen/Command.html">Command</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandInfo" data-name="cligen::commandinfo">
<a href="../CliGen/CommandInfo.html">CommandInfo</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandNode" data-name="cligen::commandnode">
<a href="../CliGen/CommandNode.html">CommandNode</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/DefaultFlag" data-name="cligen::defaultflag">
<a href="../CliGen/DefaultFlag.html">DefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Flag" data-name="cligen::flag(t)">
<a href="../CliGen/Flag.html">Flag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Format" data-name="cligen::format">
<a href="../CliGen/Format.html">Format</a>
</li>
<li class=" current" data-id="CliGenerator/CliGen/MatchType" data-name="cligen::matchtype">
<a href="../CliGen/MatchType.html">MatchType</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/ProxyCommand" data-name="cligen::proxycommand">
<a href="../CliGen/ProxyCommand.html">ProxyCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Regex" data-name="cligen::regex">
<a href="../CliGen/Regex.html">Regex</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Selection" data-name="cligen::selection">
<a href="../CliGen/Selection.html">Selection</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/SubCommand" data-name="cligen::subcommand">
<a href="../CliGen/SubCommand.html">SubCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Trigger" data-name="cligen::trigger">
<a href="../CliGen/Trigger.html">Trigger</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="main-content">
<h1 class="type-name">
<span class="kind">
enum
</span> CliGen::<wbr>MatchType
</h1>
<h2>
<a id="defined-in" class="anchor" href="#defined-in">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Defined in:
</h2>
cligen/match_type.cr
<br/>
<h2>
<a id="enum-members" class="anchor" href="#enum-members">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Enum Members
</h2>
<dl>
<dt class="entry-const" id="FlagWithArg">
<strong>FlagWithArg</strong> = <code><span class="n">0</span></code>
</dt>
<dt class="entry-const" id="FlagMultipleShort">
<strong>FlagMultipleShort</strong> = <code><span class="n">1</span></code>
</dt>
<dt class="entry-const" id="ShortWithInlineArg">
<strong>ShortWithInlineArg</strong> = <code><span class="n">2</span></code>
</dt>
<dt class="entry-const" id="NoMatch">
<strong>NoMatch</strong> = <code><span class="n">3</span></code>
</dt>
</dl>
<h2>
<a id="instance-method-summary" class="anchor" href="#instance-method-summary">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Instance Method Summary
</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#flag_multiple_short%3F-instance-method" class="signature"><strong>#flag_multiple_short?</strong></a>
<div class="summary"><p>Returns <code>true</code> if this enum value equals <code><a href="../CliGen/MatchType.html#FlagMultipleShort">FlagMultipleShort</a></code></p></div>
</li>
<li class="entry-summary">
<a href="#flag_with_arg%3F-instance-method" class="signature"><strong>#flag_with_arg?</strong></a>
<div class="summary"><p>Returns <code>true</code> if this enum value equals <code><a href="../CliGen/MatchType.html#FlagWithArg">FlagWithArg</a></code></p></div>
</li>
<li class="entry-summary">
<a href="#no_match%3F-instance-method" class="signature"><strong>#no_match?</strong></a>
<div class="summary"><p>Returns <code>true</code> if this enum value equals <code><a href="../CliGen/MatchType.html#NoMatch">NoMatch</a></code></p></div>
</li>
<li class="entry-summary">
<a href="#short_with_inline_arg%3F-instance-method" class="signature"><strong>#short_with_inline_arg?</strong></a>
<div class="summary"><p>Returns <code>true</code> if this enum value equals <code><a href="../CliGen/MatchType.html#ShortWithInlineArg">ShortWithInlineArg</a></code></p></div>
</li>
</ul>
<div class="methods-inherited">
</div>
<h2>
<a id="instance-method-detail" class="anchor" href="#instance-method-detail">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Instance Method Detail
</h2>
<div class="entry-detail" id="flag_multiple_short?-instance-method">
<div class="signature">
def <strong>flag_multiple_short?</strong>
<a class="method-permalink" href="#flag_multiple_short%3F-instance-method">#</a>
</div>
<div class="doc">
<p>Returns <code>true</code> if this enum value equals <code><a href="../CliGen/MatchType.html#FlagMultipleShort">FlagMultipleShort</a></code></p>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="flag_with_arg?-instance-method">
<div class="signature">
def <strong>flag_with_arg?</strong>
<a class="method-permalink" href="#flag_with_arg%3F-instance-method">#</a>
</div>
<div class="doc">
<p>Returns <code>true</code> if this enum value equals <code><a href="../CliGen/MatchType.html#FlagWithArg">FlagWithArg</a></code></p>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="no_match?-instance-method">
<div class="signature">
def <strong>no_match?</strong>
<a class="method-permalink" href="#no_match%3F-instance-method">#</a>
</div>
<div class="doc">
<p>Returns <code>true</code> if this enum value equals <code><a href="../CliGen/MatchType.html#NoMatch">NoMatch</a></code></p>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="short_with_inline_arg?-instance-method">
<div class="signature">
def <strong>short_with_inline_arg?</strong>
<a class="method-permalink" href="#short_with_inline_arg%3F-instance-method">#</a>
</div>
<div class="doc">
<p>Returns <code>true</code> if this enum value equals <code><a href="../CliGen/MatchType.html#ShortWithInlineArg">ShortWithInlineArg</a></code></p>
</div>
<br/>
<div>
</div>
</div>
</div>
</body>
</html>
+233
View File
@@ -0,0 +1,233 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Crystal Docs 1.20.3">
<meta name="crystal_docs.project_version" content="object_rework-dev">
<meta name="crystal_docs.project_name" content="CliGenerator">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<meta name="repository-name" content="CliGenerator">
<title>CliGen::ProxyCommand - CliGenerator object_rework-dev</title>
<script type="text/javascript">
CrystalDocs.base_path = "../";
</script>
</head>
<body>
<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill="currentColor" fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>
<input type="checkbox" id="sidebar-btn">
<label for="sidebar-btn" id="sidebar-btn-label">
<svg class="open" xmlns="http://www.w3.org/2000/svg" height="2em" width="2em" viewBox="0 0 512 512"><title>Open Sidebar</title><path fill="currentColor" d="M80 96v64h352V96H80zm0 112v64h352v-64H80zm0 112v64h352v-64H80z"></path></svg>
<svg class="close" xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" viewBox="0 0 512 512"><title>Close Sidebar</title><path fill="currentColor" d="m118.6 73.4-45.2 45.2L210.7 256 73.4 393.4l45.2 45.2L256 301.3l137.4 137.3 45.2-45.2L301.3 256l137.3-137.4-45.2-45.2L256 210.7Z"></path></svg>
</label>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
<input type="search" class="search-input" placeholder="Search..." spellcheck="false" aria-label="Search">
</div>
<div class="project-summary">
<h1 class="project-name">
<a href="../index.html">
CliGenerator
</a>
</h1>
<span class="project-version">
object_rework-dev
</span>
</div>
</div>
<div class="search-results hidden">
<ul class="search-list"></ul>
</div>
<div class="types-list">
<ul>
<li class="parent open current" data-id="CliGenerator/CliGen" data-name="cligen">
<a href="../CliGen.html">CliGen</a>
<ul>
<li class=" " data-id="CliGenerator/CliGen/AdditionalDefaultFlag" data-name="cligen::additionaldefaultflag">
<a href="../CliGen/AdditionalDefaultFlag.html">AdditionalDefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/App" data-name="cligen::app">
<a href="../CliGen/App.html">App</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Arg" data-name="cligen::arg">
<a href="../CliGen/Arg.html">Arg</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Argument" data-name="cligen::argument">
<a href="../CliGen/Argument.html">Argument</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/BaseFlag" data-name="cligen::baseflag">
<a href="../CliGen/BaseFlag.html">BaseFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Command" data-name="cligen::command">
<a href="../CliGen/Command.html">Command</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandInfo" data-name="cligen::commandinfo">
<a href="../CliGen/CommandInfo.html">CommandInfo</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandNode" data-name="cligen::commandnode">
<a href="../CliGen/CommandNode.html">CommandNode</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/DefaultFlag" data-name="cligen::defaultflag">
<a href="../CliGen/DefaultFlag.html">DefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Flag" data-name="cligen::flag(t)">
<a href="../CliGen/Flag.html">Flag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Format" data-name="cligen::format">
<a href="../CliGen/Format.html">Format</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/MatchType" data-name="cligen::matchtype">
<a href="../CliGen/MatchType.html">MatchType</a>
</li>
<li class=" current" data-id="CliGenerator/CliGen/ProxyCommand" data-name="cligen::proxycommand">
<a href="../CliGen/ProxyCommand.html">ProxyCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Regex" data-name="cligen::regex">
<a href="../CliGen/Regex.html">Regex</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Selection" data-name="cligen::selection">
<a href="../CliGen/Selection.html">Selection</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/SubCommand" data-name="cligen::subcommand">
<a href="../CliGen/SubCommand.html">SubCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Trigger" data-name="cligen::trigger">
<a href="../CliGen/Trigger.html">Trigger</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="main-content">
<h1 class="type-name">
<span class="kind">
annotation
</span> CliGen::<wbr>ProxyCommand
</h1>
<h2>
<a id="defined-in" class="anchor" href="#defined-in">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Defined in:
</h2>
cligen/annotations.cr
<br/>
<div class="methods-inherited">
</div>
</div>
</body>
</html>
+277
View File
@@ -0,0 +1,277 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Crystal Docs 1.20.3">
<meta name="crystal_docs.project_version" content="object_rework-dev">
<meta name="crystal_docs.project_name" content="CliGenerator">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<meta name="repository-name" content="CliGenerator">
<title>CliGen::Regex - CliGenerator object_rework-dev</title>
<script type="text/javascript">
CrystalDocs.base_path = "../";
</script>
</head>
<body>
<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill="currentColor" fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>
<input type="checkbox" id="sidebar-btn">
<label for="sidebar-btn" id="sidebar-btn-label">
<svg class="open" xmlns="http://www.w3.org/2000/svg" height="2em" width="2em" viewBox="0 0 512 512"><title>Open Sidebar</title><path fill="currentColor" d="M80 96v64h352V96H80zm0 112v64h352v-64H80zm0 112v64h352v-64H80z"></path></svg>
<svg class="close" xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" viewBox="0 0 512 512"><title>Close Sidebar</title><path fill="currentColor" d="m118.6 73.4-45.2 45.2L210.7 256 73.4 393.4l45.2 45.2L256 301.3l137.4 137.3 45.2-45.2L301.3 256l137.3-137.4-45.2-45.2L256 210.7Z"></path></svg>
</label>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
<input type="search" class="search-input" placeholder="Search..." spellcheck="false" aria-label="Search">
</div>
<div class="project-summary">
<h1 class="project-name">
<a href="../index.html">
CliGenerator
</a>
</h1>
<span class="project-version">
object_rework-dev
</span>
</div>
</div>
<div class="search-results hidden">
<ul class="search-list"></ul>
</div>
<div class="types-list">
<ul>
<li class="parent open current" data-id="CliGenerator/CliGen" data-name="cligen">
<a href="../CliGen.html">CliGen</a>
<ul>
<li class=" " data-id="CliGenerator/CliGen/AdditionalDefaultFlag" data-name="cligen::additionaldefaultflag">
<a href="../CliGen/AdditionalDefaultFlag.html">AdditionalDefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/App" data-name="cligen::app">
<a href="../CliGen/App.html">App</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Arg" data-name="cligen::arg">
<a href="../CliGen/Arg.html">Arg</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Argument" data-name="cligen::argument">
<a href="../CliGen/Argument.html">Argument</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/BaseFlag" data-name="cligen::baseflag">
<a href="../CliGen/BaseFlag.html">BaseFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Command" data-name="cligen::command">
<a href="../CliGen/Command.html">Command</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandInfo" data-name="cligen::commandinfo">
<a href="../CliGen/CommandInfo.html">CommandInfo</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandNode" data-name="cligen::commandnode">
<a href="../CliGen/CommandNode.html">CommandNode</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/DefaultFlag" data-name="cligen::defaultflag">
<a href="../CliGen/DefaultFlag.html">DefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Flag" data-name="cligen::flag(t)">
<a href="../CliGen/Flag.html">Flag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Format" data-name="cligen::format">
<a href="../CliGen/Format.html">Format</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/MatchType" data-name="cligen::matchtype">
<a href="../CliGen/MatchType.html">MatchType</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/ProxyCommand" data-name="cligen::proxycommand">
<a href="../CliGen/ProxyCommand.html">ProxyCommand</a>
</li>
<li class=" current" data-id="CliGenerator/CliGen/Regex" data-name="cligen::regex">
<a href="../CliGen/Regex.html">Regex</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Selection" data-name="cligen::selection">
<a href="../CliGen/Selection.html">Selection</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/SubCommand" data-name="cligen::subcommand">
<a href="../CliGen/SubCommand.html">SubCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Trigger" data-name="cligen::trigger">
<a href="../CliGen/Trigger.html">Trigger</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="main-content">
<h1 class="type-name">
<span class="kind">
module
</span> CliGen::<wbr>Regex
</h1>
<h2>
<a id="defined-in" class="anchor" href="#defined-in">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Defined in:
</h2>
cligen/regex.cr
<br/>
<h2>
<a id="constant-summary" class="anchor" href="#constant-summary">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Constant Summary
</h2>
<dl>
<dt class="entry-const" id="FLAG_MULTIPLE_SHORT">
<strong>FLAG_MULTIPLE_SHORT</strong> = <code><span class="s">/^-[a-zA-Z]+$/</span></code>
</dt>
<dt class="entry-const" id="FLAG_REGEX">
<strong>FLAG_REGEX</strong> = <code><span class="s">/^(-[a-zA-Z]|--[a-zA-Z-_]+)$/</span></code>
</dt>
<dt class="entry-const" id="FLAG_WITH_ARG">
<strong>FLAG_WITH_ARG</strong> = <code><span class="s">/^(?&lt;flag&gt;(-[a-zA-Z]|--[a-zA-Z-_]+))=&quot;?(?&lt;arg&gt;\S+?)&quot;?$/</span></code>
</dt>
<dt class="entry-const" id="INPUT_DATE_REGEX">
<strong>INPUT_DATE_REGEX</strong> = <code><span class="s">/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/</span></code>
</dt>
<dt class="entry-const" id="INPUT_DATETIME_REGEX">
<strong>INPUT_DATETIME_REGEX</strong> = <code><span class="s">/^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$/</span></code>
</dt>
<dt class="entry-const" id="SHORT_WITH_INLINE_ARG">
<strong>SHORT_WITH_INLINE_ARG</strong> = <code><span class="s">/^-[a-zA-Z][a-zA-Z0-9]+$/</span></code>
</dt>
</dl>
<div class="methods-inherited">
</div>
</div>
</body>
</html>
+233
View File
@@ -0,0 +1,233 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Crystal Docs 1.20.3">
<meta name="crystal_docs.project_version" content="object_rework-dev">
<meta name="crystal_docs.project_name" content="CliGenerator">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<meta name="repository-name" content="CliGenerator">
<title>CliGen::Selection - CliGenerator object_rework-dev</title>
<script type="text/javascript">
CrystalDocs.base_path = "../";
</script>
</head>
<body>
<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill="currentColor" fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>
<input type="checkbox" id="sidebar-btn">
<label for="sidebar-btn" id="sidebar-btn-label">
<svg class="open" xmlns="http://www.w3.org/2000/svg" height="2em" width="2em" viewBox="0 0 512 512"><title>Open Sidebar</title><path fill="currentColor" d="M80 96v64h352V96H80zm0 112v64h352v-64H80zm0 112v64h352v-64H80z"></path></svg>
<svg class="close" xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" viewBox="0 0 512 512"><title>Close Sidebar</title><path fill="currentColor" d="m118.6 73.4-45.2 45.2L210.7 256 73.4 393.4l45.2 45.2L256 301.3l137.4 137.3 45.2-45.2L301.3 256l137.3-137.4-45.2-45.2L256 210.7Z"></path></svg>
</label>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
<input type="search" class="search-input" placeholder="Search..." spellcheck="false" aria-label="Search">
</div>
<div class="project-summary">
<h1 class="project-name">
<a href="../index.html">
CliGenerator
</a>
</h1>
<span class="project-version">
object_rework-dev
</span>
</div>
</div>
<div class="search-results hidden">
<ul class="search-list"></ul>
</div>
<div class="types-list">
<ul>
<li class="parent open current" data-id="CliGenerator/CliGen" data-name="cligen">
<a href="../CliGen.html">CliGen</a>
<ul>
<li class=" " data-id="CliGenerator/CliGen/AdditionalDefaultFlag" data-name="cligen::additionaldefaultflag">
<a href="../CliGen/AdditionalDefaultFlag.html">AdditionalDefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/App" data-name="cligen::app">
<a href="../CliGen/App.html">App</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Arg" data-name="cligen::arg">
<a href="../CliGen/Arg.html">Arg</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Argument" data-name="cligen::argument">
<a href="../CliGen/Argument.html">Argument</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/BaseFlag" data-name="cligen::baseflag">
<a href="../CliGen/BaseFlag.html">BaseFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Command" data-name="cligen::command">
<a href="../CliGen/Command.html">Command</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandInfo" data-name="cligen::commandinfo">
<a href="../CliGen/CommandInfo.html">CommandInfo</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandNode" data-name="cligen::commandnode">
<a href="../CliGen/CommandNode.html">CommandNode</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/DefaultFlag" data-name="cligen::defaultflag">
<a href="../CliGen/DefaultFlag.html">DefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Flag" data-name="cligen::flag(t)">
<a href="../CliGen/Flag.html">Flag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Format" data-name="cligen::format">
<a href="../CliGen/Format.html">Format</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/MatchType" data-name="cligen::matchtype">
<a href="../CliGen/MatchType.html">MatchType</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/ProxyCommand" data-name="cligen::proxycommand">
<a href="../CliGen/ProxyCommand.html">ProxyCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Regex" data-name="cligen::regex">
<a href="../CliGen/Regex.html">Regex</a>
</li>
<li class=" current" data-id="CliGenerator/CliGen/Selection" data-name="cligen::selection">
<a href="../CliGen/Selection.html">Selection</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/SubCommand" data-name="cligen::subcommand">
<a href="../CliGen/SubCommand.html">SubCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Trigger" data-name="cligen::trigger">
<a href="../CliGen/Trigger.html">Trigger</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="main-content">
<h1 class="type-name">
<span class="kind">
annotation
</span> CliGen::<wbr>Selection
</h1>
<h2>
<a id="defined-in" class="anchor" href="#defined-in">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Defined in:
</h2>
cligen/annotations.cr
<br/>
<div class="methods-inherited">
</div>
</div>
</body>
</html>
+233
View File
@@ -0,0 +1,233 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Crystal Docs 1.20.3">
<meta name="crystal_docs.project_version" content="object_rework-dev">
<meta name="crystal_docs.project_name" content="CliGenerator">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<meta name="repository-name" content="CliGenerator">
<title>CliGen::SubCommand - CliGenerator object_rework-dev</title>
<script type="text/javascript">
CrystalDocs.base_path = "../";
</script>
</head>
<body>
<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill="currentColor" fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>
<input type="checkbox" id="sidebar-btn">
<label for="sidebar-btn" id="sidebar-btn-label">
<svg class="open" xmlns="http://www.w3.org/2000/svg" height="2em" width="2em" viewBox="0 0 512 512"><title>Open Sidebar</title><path fill="currentColor" d="M80 96v64h352V96H80zm0 112v64h352v-64H80zm0 112v64h352v-64H80z"></path></svg>
<svg class="close" xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" viewBox="0 0 512 512"><title>Close Sidebar</title><path fill="currentColor" d="m118.6 73.4-45.2 45.2L210.7 256 73.4 393.4l45.2 45.2L256 301.3l137.4 137.3 45.2-45.2L301.3 256l137.3-137.4-45.2-45.2L256 210.7Z"></path></svg>
</label>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
<input type="search" class="search-input" placeholder="Search..." spellcheck="false" aria-label="Search">
</div>
<div class="project-summary">
<h1 class="project-name">
<a href="../index.html">
CliGenerator
</a>
</h1>
<span class="project-version">
object_rework-dev
</span>
</div>
</div>
<div class="search-results hidden">
<ul class="search-list"></ul>
</div>
<div class="types-list">
<ul>
<li class="parent open current" data-id="CliGenerator/CliGen" data-name="cligen">
<a href="../CliGen.html">CliGen</a>
<ul>
<li class=" " data-id="CliGenerator/CliGen/AdditionalDefaultFlag" data-name="cligen::additionaldefaultflag">
<a href="../CliGen/AdditionalDefaultFlag.html">AdditionalDefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/App" data-name="cligen::app">
<a href="../CliGen/App.html">App</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Arg" data-name="cligen::arg">
<a href="../CliGen/Arg.html">Arg</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Argument" data-name="cligen::argument">
<a href="../CliGen/Argument.html">Argument</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/BaseFlag" data-name="cligen::baseflag">
<a href="../CliGen/BaseFlag.html">BaseFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Command" data-name="cligen::command">
<a href="../CliGen/Command.html">Command</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandInfo" data-name="cligen::commandinfo">
<a href="../CliGen/CommandInfo.html">CommandInfo</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandNode" data-name="cligen::commandnode">
<a href="../CliGen/CommandNode.html">CommandNode</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/DefaultFlag" data-name="cligen::defaultflag">
<a href="../CliGen/DefaultFlag.html">DefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Flag" data-name="cligen::flag(t)">
<a href="../CliGen/Flag.html">Flag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Format" data-name="cligen::format">
<a href="../CliGen/Format.html">Format</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/MatchType" data-name="cligen::matchtype">
<a href="../CliGen/MatchType.html">MatchType</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/ProxyCommand" data-name="cligen::proxycommand">
<a href="../CliGen/ProxyCommand.html">ProxyCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Regex" data-name="cligen::regex">
<a href="../CliGen/Regex.html">Regex</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Selection" data-name="cligen::selection">
<a href="../CliGen/Selection.html">Selection</a>
</li>
<li class=" current" data-id="CliGenerator/CliGen/SubCommand" data-name="cligen::subcommand">
<a href="../CliGen/SubCommand.html">SubCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Trigger" data-name="cligen::trigger">
<a href="../CliGen/Trigger.html">Trigger</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="main-content">
<h1 class="type-name">
<span class="kind">
annotation
</span> CliGen::<wbr>SubCommand
</h1>
<h2>
<a id="defined-in" class="anchor" href="#defined-in">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Defined in:
</h2>
cligen/annotations.cr
<br/>
<div class="methods-inherited">
</div>
</div>
</body>
</html>
+233
View File
@@ -0,0 +1,233 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Crystal Docs 1.20.3">
<meta name="crystal_docs.project_version" content="object_rework-dev">
<meta name="crystal_docs.project_name" content="CliGenerator">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<meta name="repository-name" content="CliGenerator">
<title>CliGen::Trigger - CliGenerator object_rework-dev</title>
<script type="text/javascript">
CrystalDocs.base_path = "../";
</script>
</head>
<body>
<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill="currentColor" fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>
<input type="checkbox" id="sidebar-btn">
<label for="sidebar-btn" id="sidebar-btn-label">
<svg class="open" xmlns="http://www.w3.org/2000/svg" height="2em" width="2em" viewBox="0 0 512 512"><title>Open Sidebar</title><path fill="currentColor" d="M80 96v64h352V96H80zm0 112v64h352v-64H80zm0 112v64h352v-64H80z"></path></svg>
<svg class="close" xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" viewBox="0 0 512 512"><title>Close Sidebar</title><path fill="currentColor" d="m118.6 73.4-45.2 45.2L210.7 256 73.4 393.4l45.2 45.2L256 301.3l137.4 137.3 45.2-45.2L301.3 256l137.3-137.4-45.2-45.2L256 210.7Z"></path></svg>
</label>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
<input type="search" class="search-input" placeholder="Search..." spellcheck="false" aria-label="Search">
</div>
<div class="project-summary">
<h1 class="project-name">
<a href="../index.html">
CliGenerator
</a>
</h1>
<span class="project-version">
object_rework-dev
</span>
</div>
</div>
<div class="search-results hidden">
<ul class="search-list"></ul>
</div>
<div class="types-list">
<ul>
<li class="parent open current" data-id="CliGenerator/CliGen" data-name="cligen">
<a href="../CliGen.html">CliGen</a>
<ul>
<li class=" " data-id="CliGenerator/CliGen/AdditionalDefaultFlag" data-name="cligen::additionaldefaultflag">
<a href="../CliGen/AdditionalDefaultFlag.html">AdditionalDefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/App" data-name="cligen::app">
<a href="../CliGen/App.html">App</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Arg" data-name="cligen::arg">
<a href="../CliGen/Arg.html">Arg</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Argument" data-name="cligen::argument">
<a href="../CliGen/Argument.html">Argument</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/BaseFlag" data-name="cligen::baseflag">
<a href="../CliGen/BaseFlag.html">BaseFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Command" data-name="cligen::command">
<a href="../CliGen/Command.html">Command</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandInfo" data-name="cligen::commandinfo">
<a href="../CliGen/CommandInfo.html">CommandInfo</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandNode" data-name="cligen::commandnode">
<a href="../CliGen/CommandNode.html">CommandNode</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/DefaultFlag" data-name="cligen::defaultflag">
<a href="../CliGen/DefaultFlag.html">DefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Flag" data-name="cligen::flag(t)">
<a href="../CliGen/Flag.html">Flag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Format" data-name="cligen::format">
<a href="../CliGen/Format.html">Format</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/MatchType" data-name="cligen::matchtype">
<a href="../CliGen/MatchType.html">MatchType</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/ProxyCommand" data-name="cligen::proxycommand">
<a href="../CliGen/ProxyCommand.html">ProxyCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Regex" data-name="cligen::regex">
<a href="../CliGen/Regex.html">Regex</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Selection" data-name="cligen::selection">
<a href="../CliGen/Selection.html">Selection</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/SubCommand" data-name="cligen::subcommand">
<a href="../CliGen/SubCommand.html">SubCommand</a>
</li>
<li class=" current" data-id="CliGenerator/CliGen/Trigger" data-name="cligen::trigger">
<a href="../CliGen/Trigger.html">Trigger</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="main-content">
<h1 class="type-name">
<span class="kind">
annotation
</span> CliGen::<wbr>Trigger
</h1>
<h2>
<a id="defined-in" class="anchor" href="#defined-in">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Defined in:
</h2>
cligen/annotations.cr
<br/>
<div class="methods-inherited">
</div>
</div>
</body>
</html>
+988
View File
@@ -0,0 +1,988 @@
:root {
color-scheme: light dark;
}
html, body {
background: #FFFFFF;
position: relative;
margin: 0;
padding: 0;
width: 100%;
height: 100%;
overflow: hidden;
}
body {
font-family: "Avenir", "Tahoma", "Lucida Sans", "Lucida Grande", Verdana, Arial, sans-serif;
color: #333;
line-height: 1.5;
}
a {
color: #263F6C;
}
a:visited {
color: #112750;
}
h1, h2, h3, h4, h5, h6 {
margin: 35px 0 25px;
color: #444444;
}
h1.type-name {
color: #47266E;
margin: 20px 0 30px;
background-color: #F8F8F8;
padding: 10px 12px;
border: 1px solid #EBEBEB;
border-radius: 2px;
}
h2 {
border-bottom: 1px solid #E6E6E6;
padding-bottom: 5px;
}
body {
display: flex;
}
.sidebar, .main-content {
overflow: auto;
}
p, li {
max-width: 42em;
}
.methods-inherited {
max-width: 60em;
}
.sidebar {
width: 30em;
color: #F8F4FD;
background-color: #2E1052;
padding: 0 0 30px;
box-shadow: inset -3px 0 4px rgba(0,0,0,.35);
line-height: 1.2;
z-index: 0;
}
.sidebar .search-box {
padding: 13px 9px;
}
.sidebar input {
display: block;
box-sizing: border-box;
margin: 0;
padding: 5px;
font: inherit;
font-family: inherit;
line-height: 1.2;
width: 100%;
border: 0;
outline: 0;
border-radius: 2px;
box-shadow: 0px 3px 5px rgba(0,0,0,.25);
transition: box-shadow .12s;
}
.sidebar input:focus {
box-shadow: 0px 5px 6px rgba(0,0,0,.5);
}
.sidebar input::-webkit-input-placeholder { /* Chrome/Opera/Safari */
color: #757575;
font-size: 14px;
text-indent: 2px;
}
.sidebar input::-moz-placeholder { /* Firefox 19+ */
color: #757575;
font-size: 14px;
text-indent: 2px;
}
.sidebar input:-ms-input-placeholder { /* IE 10+ */
color: #757575;
font-size: 14px;
text-indent: 2px;
}
.sidebar input:-moz-placeholder { /* Firefox 18- */
color: #757575;
font-size: 14px;
text-indent: 2px;
}
.project-summary {
padding: 9px 15px 30px 30px;
}
.project-name {
font-size: 1.4rem;
margin: 0;
color: #f4f4f4;
font-weight: 600;
}
.project-version {
margin-top: 5px;
display: inline-block;
position: relative;
}
.project-version > form::after {
position: absolute;
right: 0;
top: 0;
content: "\25BC";
font-size: .6em;
line-height: 1.2rem;
z-index: -1;
}
.project-versions-nav {
cursor: pointer;
margin: 0;
padding: 0 .9em 0 0;
border: none;
-moz-appearance: none;
-webkit-appearance: none;
appearance: none;
background-color: transparent;
color: inherit;
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
.project-versions-nav:focus {
outline: none;
}
.project-versions-nav > option {
color: initial;
}
.sidebar ul {
margin: 0;
padding: 0;
list-style: none outside;
}
.sidebar li {
display: block;
position: relative;
}
.types-list li.hide {
display: none;
}
.sidebar a {
text-decoration: none;
color: inherit;
transition: color .14s;
}
.types-list a {
display: block;
padding: 5px 15px 5px 30px;
}
.types-list {
display: block;
}
.sidebar a:focus {
outline: 1px solid #D1B7F1;
}
.types-list a {
padding: 5px 15px 5px 30px;
}
.sidebar .current > a,
.sidebar a:hover {
color: #866BA6;
}
.types-list li ul {
overflow: hidden;
height: 0;
max-height: 0;
transition: 1s ease-in-out;
}
.types-list li.parent {
padding-left: 30px;
}
.types-list li.parent::before {
box-sizing: border-box;
content: "▼";
display: block;
width: 30px;
height: 30px;
position: absolute;
top: 0;
left: 0;
text-align: center;
color: white;
font-size: 8px;
line-height: 30px;
transform: rotateZ(-90deg);
cursor: pointer;
transition: .2s linear;
}
.types-list li.parent > a {
padding-left: 0;
}
.types-list li.parent.open::before {
transform: rotateZ(0);
}
.types-list li.open > ul {
height: auto;
max-height: 1000em;
}
.main-content {
padding: 0 30px 30px 30px;
width: 100%;
}
.kind {
font-size: 60%;
color: #866BA6;
}
.superclass-hierarchy {
margin: -15px 0 30px 0;
padding: 0;
list-style: none outside;
font-size: 80%;
}
.superclass-hierarchy .superclass {
display: inline-block;
margin: 0 7px 0 0;
padding: 0;
}
.superclass-hierarchy .superclass + .superclass::before {
content: "<";
margin-right: 7px;
}
.other-types-list li {
display: inline-block;
}
.other-types-list,
.list-summary {
margin: 0 0 30px 0;
padding: 0;
list-style: none outside;
}
.entry-const {
font-family: Menlo, Monaco, Consolas, 'Courier New', Courier, monospace;
}
.entry-const code {
white-space: pre-wrap;
}
.entry-summary {
padding-bottom: 4px;
}
.superclass-hierarchy .superclass a,
.other-type a,
.entry-summary .signature {
padding: 4px 8px;
margin-bottom: 4px;
display: inline-block;
background-color: #f8f8f8;
color: #47266E;
border: 1px solid #f0f0f0;
text-decoration: none;
border-radius: 3px;
font-family: Menlo, Monaco, Consolas, 'Courier New', Courier, monospace;
transition: background .15s, border-color .15s;
}
.superclass-hierarchy .superclass a:hover,
.other-type a:hover,
.entry-summary .signature:hover {
background: #D5CAE3;
border-color: #624288;
}
.entry-summary .summary {
padding-left: 32px;
}
.entry-summary .summary p {
margin: 12px 0 16px;
}
.entry-summary a {
text-decoration: none;
}
.entry-detail {
padding: 30px 0;
}
.entry-detail .signature {
position: relative;
padding: 5px 15px;
margin-bottom: 10px;
display: block;
border-radius: 5px;
background-color: #f8f8f8;
color: #47266E;
border: 1px solid #f0f0f0;
font-family: Menlo, Monaco, Consolas, 'Courier New', Courier, monospace;
transition: .2s ease-in-out;
}
.entry-detail:target .signature {
background-color: #D5CAE3;
border: 1px solid #624288;
}
.entry-detail .signature .method-permalink {
position: absolute;
top: 0;
left: -35px;
padding: 5px 15px;
text-decoration: none;
font-weight: bold;
color: #624288;
opacity: .4;
transition: opacity .2s;
}
.entry-detail .signature .method-permalink:hover {
opacity: 1;
}
.entry-detail:target .signature .method-permalink {
opacity: 1;
}
.methods-inherited {
padding-right: 10%;
line-height: 1.5em;
}
.methods-inherited h3 {
margin-bottom: 4px;
}
.methods-inherited a {
display: inline-block;
text-decoration: none;
color: #47266E;
}
.methods-inherited a:hover {
text-decoration: underline;
color: #6C518B;
}
.methods-inherited .tooltip>span {
background: #D5CAE3;
padding: 4px 8px;
border-radius: 3px;
margin: -4px -8px;
}
.methods-inherited .tooltip * {
color: #47266E;
}
pre {
padding: 10px 20px;
margin-top: 4px;
border-radius: 3px;
line-height: 1.45;
overflow: auto;
color: #333;
background: #fdfdfd;
font-size: 14px;
border: 1px solid #eee;
}
code {
font-family: Menlo, Monaco, Consolas, 'Courier New', Courier, monospace;
}
:not(pre) > code {
background-color: rgba(40,35,30,0.05);
padding: 0.2em 0.4em;
font-size: 85%;
border-radius: 3px;
}
span.flag {
padding: 2px 4px 1px;
border-radius: 3px;
margin-right: 3px;
font-size: 11px;
border: 1px solid transparent;
}
span.flag.orange {
background-color: #EE8737;
color: #FCEBDD;
border-color: #EB7317;
}
span.flag.yellow {
background-color: #E4B91C;
color: #FCF8E8;
border-color: #B69115;
}
span.flag.green {
background-color: #469C14;
color: #E2F9D3;
border-color: #34700E;
}
span.flag.red {
background-color: #BF1919;
color: #F9ECEC;
border-color: #822C2C;
}
span.flag.purple {
background-color: #2E1052;
color: #ECE1F9;
border-color: #1F0B37;
}
span.flag.lime {
background-color: #a3ff00;
color: #222222;
border-color: #00ff1e;
}
.tooltip>span {
position: absolute;
opacity: 0;
display: none;
pointer-events: none;
}
.tooltip:hover>span {
display: inline-block;
opacity: 1;
}
.c {
color: #969896;
}
.n {
color: #0086b3;
}
.t {
color: #0086b3;
}
.s {
color: #183691;
}
.i {
color: #7f5030;
}
.k {
color: #a71d5d;
}
.o {
color: #a71d5d;
}
.m {
color: #795da3;
}
.hidden {
display: none;
}
.search-results {
font-size: 90%;
line-height: 1.3;
}
.search-results mark {
color: inherit;
background: transparent;
font-weight: bold;
}
.search-result {
padding: 5px 8px 5px 5px;
cursor: pointer;
border-left: 5px solid transparent;
transform: translateX(-3px);
transition: all .2s, background-color 0s, border .02s;
min-height: 3.2em;
}
.search-result.current {
border-left-color: #ddd;
background-color: rgba(200,200,200,0.4);
transform: translateX(0);
transition: all .2s, background-color .5s, border 0s;
}
.search-result.current:hover,
.search-result.current:focus {
border-left-color: #866BA6;
}
.search-result:not(.current):nth-child(2n) {
background-color: rgba(255,255,255,.06);
}
.search-result__title {
font-size: 105%;
word-break: break-all;
line-height: 1.1;
padding: 3px 0;
}
.search-result__title strong {
font-weight: normal;
}
.search-results .search-result__title > a {
padding: 0;
display: block;
}
.search-result__title > a > .args {
color: #dddddd;
font-weight: 300;
transition: inherit;
font-size: 88%;
line-height: 1.2;
letter-spacing: -.02em;
}
.search-result__title > a > .args * {
color: inherit;
}
.search-result a,
.search-result a:hover {
color: inherit;
}
.search-result:not(.current):hover .search-result__title > a,
.search-result:not(.current):focus .search-result__title > a,
.search-result__title > a:focus {
color: #866BA6;
}
.search-result:not(.current):hover .args,
.search-result:not(.current):focus .args {
color: #6a5a7d;
}
.search-result__type {
color: #e8e8e8;
font-weight: 300;
}
.search-result__doc {
color: #bbbbbb;
font-size: 90%;
}
.search-result__doc p {
margin: 0;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
line-height: 1.2em;
max-height: 2.4em;
}
.js-modal-visible .modal-background {
display: flex;
}
.main-content {
position: relative;
}
.modal-background {
position: absolute;
display: none;
height: 100%;
width: 100%;
background: rgba(120,120,120,.4);
z-index: 100;
align-items: center;
justify-content: center;
}
.usage-modal {
max-width: 90%;
background: #fff;
border: 2px solid #ccc;
border-radius: 9px;
padding: 5px 15px 20px;
min-width: 50%;
color: #555;
position: relative;
transform: scale(.5);
transition: transform 200ms;
}
.js-modal-visible .usage-modal {
transform: scale(1);
}
.usage-modal > .close-button {
position: absolute;
right: 15px;
top: 8px;
color: #aaa;
font-size: 27px;
cursor: pointer;
}
.usage-modal > .close-button:hover {
text-shadow: 2px 2px 2px #ccc;
color: #999;
}
.modal-title {
margin: 0;
text-align: center;
font-weight: normal;
color: #666;
border-bottom: 2px solid #ddd;
padding: 10px;
}
.usage-list {
padding: 0;
margin: 13px;
}
.usage-list > li {
padding: 5px 2px;
overflow: auto;
padding-left: 100px;
min-width: 12em;
}
.usage-modal kbd {
background: #eee;
border: 1px solid #ccc;
border-bottom-width: 2px;
border-radius: 3px;
padding: 3px 8px;
font-family: monospace;
margin-right: 2px;
display: inline-block;
}
.usage-key {
float: left;
clear: left;
margin-left: -100px;
margin-right: 12px;
}
.doc-inherited {
font-weight: bold;
}
.anchor {
float: left;
padding-right: 4px;
margin-left: -20px;
}
.main-content .anchor .octicon-link {
width: 16px;
height: 16px;
}
.main-content .anchor:focus {
outline: none
}
.main-content h1:hover .anchor,
.main-content h2:hover .anchor,
.main-content h3:hover .anchor,
.main-content h4:hover .anchor,
.main-content h5:hover .anchor,
.main-content h6:hover .anchor {
text-decoration: none
}
.main-content h1 .octicon-link,
.main-content h2 .octicon-link,
.main-content h3 .octicon-link,
.main-content h4 .octicon-link,
.main-content h5 .octicon-link,
.main-content h6 .octicon-link {
visibility: hidden
}
.main-content h1:hover .anchor .octicon-link,
.main-content h2:hover .anchor .octicon-link,
.main-content h3:hover .anchor .octicon-link,
.main-content h4:hover .anchor .octicon-link,
.main-content h5:hover .anchor .octicon-link,
.main-content h6:hover .anchor .octicon-link {
visibility: visible
}
img {
max-width: 100%;
}
table {
font-size: 14px;
display: block;
max-width: -moz-fit-content;
max-width: fit-content;
overflow-x: auto;
white-space: nowrap;
background: #fdfdfd;
text-align: center;
border: 1px solid #eee;
border-collapse: collapse;
padding: 0px 5px 0px 5px;
}
table th {
padding: 10px;
letter-spacing: 1px;
border-bottom: 1px solid #eee;
}
table td {
padding: 10px;
}
#sidebar-btn {
height: 32px;
width: 32px;
}
#sidebar-btn-label {
height: 2em;
width: 2em;
}
#sidebar-btn, #sidebar-btn-label {
display: none;
margin: .7rem;
appearance: none;
color: black;
cursor: pointer;
}
@media only screen and (max-width: 635px) {
.sidebar, .main-content {
/* svg size + vertical margin - .search-box padding-top */
padding-top: calc(2em + 2 * 0.7rem - 13px);
}
#sidebar-btn, #sidebar-btn-label {
display: block;
position: absolute;
z-index: 50;
transition-duration: 200ms;
left: 0;
}
#sidebar-btn:not(:checked) ~ #sidebar-btn-label > .close,
#sidebar-btn:checked ~ #sidebar-btn-label > .open,
#sidebar-btn:checked ~ .main-content {
display: none;
}
#sidebar-btn:checked {
left: calc(100% - 32px - (2 * 0.7rem));
}
#sidebar-btn:checked ~ #sidebar-btn-label {
color: white;
/* 100% - svg size - horizontal margin */
left: calc(100% - 2em - (2 * 0.7rem));
}
#sidebar-btn~.sidebar {
width: 0%;
}
#sidebar-btn:checked~.sidebar {
visibility: visible;
width: 100%;
}
.sidebar {
transition-duration: 200ms;
max-width: 100vw;
visibility: hidden;
}
}
@media (prefers-color-scheme: dark) {
html, body {
background: #1b1b1b;
}
body {
color: white;
}
a {
color: #8cb4ff;
}
.main-content a:visited {
color: #5f8de3;
}
h1, h2, h3, h4, h5, h6 {
color: white;
}
h1.type-name {
color: white;
background-color: #202020;
border: 1px solid #353535;
}
.project-versions-nav > option {
background-color: #222;
}
.superclass-hierarchy .superclass a,
.superclass-hierarchy .superclass a:visited,
.other-type a,
.other-type a:visited,
.entry-summary .signature,
.entry-summary a:visited {
background-color: #202020;
color: white;
border: 1px solid #353535;
}
.superclass-hierarchy .superclass a:hover,
.other-type a:hover,
.entry-summary .signature:hover {
background: #443d4d;
border-color: #b092d4;
}
.kind {
color: #b092d4;
}
.n {
color: #00ade6;
}
.t {
color: #00ade6;
}
.k {
color: #ff66ae;
}
.o {
color: #ff66ae;
}
.s {
color: #7799ff;
}
.i {
color: #b38668;
}
.m {
color: #b9a5d6;
}
.c {
color: #a1a1a1;
}
.methods-inherited a, .methods-inherited a:visited {
color: #B290D9;
}
.methods-inherited a:hover {
color: #D4B7F4;
}
.methods-inherited .tooltip>span {
background: #443d4d;
}
.methods-inherited .tooltip * {
color: white;
}
.entry-detail:target .signature {
background-color: #443d4d;
border: 1px solid #b092d4;
}
.entry-detail .signature {
background-color: #202020;
color: white;
border: 1px solid #353535;
}
.entry-detail .signature .method-permalink {
color: #b092d4;
}
:not(pre)>code {
background-color: #202020;
}
span.flag.purple {
background-color: #443d4d;
color: #ECE1F9;
border-color: #b092d4;
}
.sidebar input::-webkit-input-placeholder { /* Chrome/Opera/Safari */
color: white;
}
.sidebar input::-moz-placeholder { /* Firefox 19+ */
color: white;
}
.sidebar input:-ms-input-placeholder { /* IE 10+ */
color: white;
}
.sidebar input:-moz-placeholder { /* Firefox 18- */
color: white;
}
pre,
table {
color: white;
background: #202020;
border: 1px solid #353535;
}
table th {
border-bottom: 1px solid #353535;
}
#sidebar-btn, #sidebar-btn-label {
color: white;
}
}
+199
View File
@@ -0,0 +1,199 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Crystal Docs 1.20.3">
<meta name="crystal_docs.project_version" content="object_rework-dev">
<meta name="crystal_docs.project_name" content="CliGenerator">
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/doc.js"></script>
<meta name="repository-name" content="CliGenerator">
<title>CliGenerator object_rework-dev</title>
<script type="text/javascript">
CrystalDocs.base_path = "";
</script>
</head>
<body>
<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill="currentColor" fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>
<input type="checkbox" id="sidebar-btn">
<label for="sidebar-btn" id="sidebar-btn-label">
<svg class="open" xmlns="http://www.w3.org/2000/svg" height="2em" width="2em" viewBox="0 0 512 512"><title>Open Sidebar</title><path fill="currentColor" d="M80 96v64h352V96H80zm0 112v64h352v-64H80zm0 112v64h352v-64H80z"></path></svg>
<svg class="close" xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" viewBox="0 0 512 512"><title>Close Sidebar</title><path fill="currentColor" d="m118.6 73.4-45.2 45.2L210.7 256 73.4 393.4l45.2 45.2L256 301.3l137.4 137.3 45.2-45.2L301.3 256l137.3-137.4-45.2-45.2L256 210.7Z"></path></svg>
</label>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
<input type="search" class="search-input" placeholder="Search..." spellcheck="false" aria-label="Search">
</div>
<div class="project-summary">
<h1 class="project-name">
<a href="index.html">
CliGenerator
</a>
</h1>
<span class="project-version">
object_rework-dev
</span>
</div>
</div>
<div class="search-results hidden">
<ul class="search-list"></ul>
</div>
<div class="types-list">
<ul>
<li class="parent " data-id="CliGenerator/CliGen" data-name="cligen">
<a href="CliGen.html">CliGen</a>
<ul>
<li class=" " data-id="CliGenerator/CliGen/AdditionalDefaultFlag" data-name="cligen::additionaldefaultflag">
<a href="CliGen/AdditionalDefaultFlag.html">AdditionalDefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/App" data-name="cligen::app">
<a href="CliGen/App.html">App</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Arg" data-name="cligen::arg">
<a href="CliGen/Arg.html">Arg</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Argument" data-name="cligen::argument">
<a href="CliGen/Argument.html">Argument</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/BaseFlag" data-name="cligen::baseflag">
<a href="CliGen/BaseFlag.html">BaseFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Command" data-name="cligen::command">
<a href="CliGen/Command.html">Command</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandInfo" data-name="cligen::commandinfo">
<a href="CliGen/CommandInfo.html">CommandInfo</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandNode" data-name="cligen::commandnode">
<a href="CliGen/CommandNode.html">CommandNode</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/DefaultFlag" data-name="cligen::defaultflag">
<a href="CliGen/DefaultFlag.html">DefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Flag" data-name="cligen::flag(t)">
<a href="CliGen/Flag.html">Flag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Format" data-name="cligen::format">
<a href="CliGen/Format.html">Format</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/MatchType" data-name="cligen::matchtype">
<a href="CliGen/MatchType.html">MatchType</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/ProxyCommand" data-name="cligen::proxycommand">
<a href="CliGen/ProxyCommand.html">ProxyCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Regex" data-name="cligen::regex">
<a href="CliGen/Regex.html">Regex</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Selection" data-name="cligen::selection">
<a href="CliGen/Selection.html">Selection</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/SubCommand" data-name="cligen::subcommand">
<a href="CliGen/SubCommand.html">SubCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Trigger" data-name="cligen::trigger">
<a href="CliGen/Trigger.html">Trigger</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="main-content">
<h1><a id="cli-generator" class="anchor" href="#cli-generator"> <svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>CliGenerator</h1>
<p>This is a crystal project to manage setting up OptionParser objects based around &quot;Command&quot; objects and arguments you define inside them.</p>
<h2><a id="installation" class="anchor" href="#installation">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>Installation</h2>
<ol>
<li>
<p>Add the dependency to your <code>shard.yml</code>:</p>
<pre><code class="language-yaml">dependencies:
cligen:
git: https://git.arcanium.tech/tristan/cligen</code></pre>
</li>
<li>
<p>Run <code>shards install</code></p>
</li>
</ol>
<h2><a id="usage" class="anchor" href="#usage">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>Usage</h2>
<pre><code class="language-crystal"><span class="k">require</span> <span class="s">&quot;cligen&quot;</span></code></pre>
<h2><a id="contributors" class="anchor" href="#contributors">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>Contributors</h2>
<ul>
<li><a href="https://git.arcanium.tech/tristan">Tristan Ancelet</a> - creator and maintainer</li>
</ul>
</div>
</body>
</html>
+1
View File
@@ -0,0 +1 @@
{"repository_name":"CliGenerator","body":"# CliGenerator\n \nThis is a crystal project to manage setting up OptionParser objects based around \"Command\" objects and arguments you define inside them.\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n ```yaml\n dependencies:\n cligen:\n git: https://git.arcanium.tech/tristan/cligen\n ```\n\n2. Run `shards install`\n\n\n## Usage\n```crystal\nrequire \"cligen\"\n```\n\n## Contributors\n\n- [Tristan Ancelet](https://git.arcanium.tech/tristan) - creator and maintainer\n","program":{"html_id":"CliGenerator/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"locations":[],"repository_name":"CliGenerator","program":true,"enum":false,"alias":false,"const":false,"types":[{"html_id":"CliGenerator/CliGen","path":"CliGen.html","kind":"module","full_name":"CliGen","name":"CliGen","abstract":false,"locations":[{"filename":"src/cligen.cr","line_number":10,"url":null},{"filename":"src/cligen/annotations.cr","line_number":1,"url":null},{"filename":"src/cligen/app.cr","line_number":5,"url":null},{"filename":"src/cligen/arg.cr","line_number":1,"url":null},{"filename":"src/cligen/command.cr","line_number":10,"url":null},{"filename":"src/cligen/command/argument.cr","line_number":1,"url":null},{"filename":"src/cligen/command/selection.cr","line_number":1,"url":null},{"filename":"src/cligen/command/subcommand.cr","line_number":1,"url":null},{"filename":"src/cligen/command/trigger.cr","line_number":1,"url":null},{"filename":"src/cligen/command_node.cr","line_number":4,"url":null},{"filename":"src/cligen/flag.cr","line_number":3,"url":null},{"filename":"src/cligen/generate.cr","line_number":2,"url":null},{"filename":"src/cligen/match_type.cr","line_number":1,"url":null}],"repository_name":"CliGenerator","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"ADDITIONAL_DEFAULT_FLAGS","name":"ADDITIONAL_DEFAULT_FLAGS","value":"[] of AdditionalDefaultFlag"},{"id":"APPNAME","name":"APPNAME","value":"File.basename(PROGRAM_NAME)"},{"id":"VERSION","name":"VERSION","value":"\"0.1.0\""}],"class_methods":[{"html_id":"add_default_flag(short:String=\"\",long:String=\"\",description:String=\"\",&work:String->)-class-method","name":"add_default_flag","abstract":false,"args":[{"name":"short","default_value":"\"\"","external_name":"short","restriction":"String"},{"name":"long","default_value":"\"\"","external_name":"long","restriction":"String"},{"name":"description","default_value":"\"\"","external_name":"description","restriction":"String"}],"args_string":"(short : String = \"\", long : String = \"\", description : String = \"\", &work : String -> )","args_html":"(short : String = <span class=\"s\">&quot;&quot;</span>, long : String = <span class=\"s\">&quot;&quot;</span>, description : String = <span class=\"s\">&quot;&quot;</span>, &work : String -> )","location":{"filename":"src/cligen.cr","line_number":23,"url":null},"def":{"name":"add_default_flag","args":[{"name":"short","default_value":"\"\"","external_name":"short","restriction":"String"},{"name":"long","default_value":"\"\"","external_name":"long","restriction":"String"},{"name":"description","default_value":"\"\"","external_name":"description","restriction":"String"}],"yields":1,"block_arity":1,"block_arg":{"name":"work","external_name":"work","restriction":"(String ->)"},"visibility":"Public","body":"if description.empty?\n raise(\"ERROR : add_default_flag : You must provide a description\")\nend\nADDITIONAL_DEFAULT_FLAGS << AdditionalDefaultFlag.new(short: short, long: long, description: description, work: work)\n"},"external_var":false}],"types":[{"html_id":"CliGenerator/CliGen/AdditionalDefaultFlag","path":"CliGen/AdditionalDefaultFlag.html","kind":"struct","full_name":"CliGen::AdditionalDefaultFlag","name":"AdditionalDefaultFlag","abstract":false,"superclass":{"html_id":"CliGenerator/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"CliGenerator/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"CliGenerator/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"CliGenerator/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cligen.cr","line_number":15,"url":null}],"repository_name":"CliGenerator","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"CliGenerator/CliGen","kind":"module","full_name":"CliGen","name":"CliGen"},"constructors":[{"html_id":"new(short:String,long:String,description:String,work:String->)-class-method","name":"new","abstract":false,"args":[{"name":"short","external_name":"short","restriction":"String"},{"name":"long","external_name":"long","restriction":"String"},{"name":"description","external_name":"description","restriction":"String"},{"name":"work","external_name":"work","restriction":"(String ->)"}],"args_string":"(short : StriLine truncated
+1099
View File
File diff suppressed because it is too large. Load diff
+1
View File
@@ -0,0 +1 @@
crystal_doc_search_index_callback({"repository_name":"CliGenerator","body":"# CliGenerator\n \nThis is a crystal project to manage setting up OptionParser objects based around \"Command\" objects and arguments you define inside them.\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n ```yaml\n dependencies:\n cligen:\n git: https://git.arcanium.tech/tristan/cligen\n ```\n\n2. Run `shards install`\n\n\n## Usage\n```crystal\nrequire \"cligen\"\n```\n\n## Contributors\n\n- [Tristan Ancelet](https://git.arcanium.tech/tristan) - creator and maintainer\n","program":{"html_id":"CliGenerator/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"locations":[],"repository_name":"CliGenerator","program":true,"enum":false,"alias":false,"const":false,"types":[{"html_id":"CliGenerator/CliGen","path":"CliGen.html","kind":"module","full_name":"CliGen","name":"CliGen","abstract":false,"locations":[{"filename":"src/cligen.cr","line_number":10,"url":null},{"filename":"src/cligen/annotations.cr","line_number":1,"url":null},{"filename":"src/cligen/app.cr","line_number":5,"url":null},{"filename":"src/cligen/arg.cr","line_number":1,"url":null},{"filename":"src/cligen/command.cr","line_number":10,"url":null},{"filename":"src/cligen/command/argument.cr","line_number":1,"url":null},{"filename":"src/cligen/command/selection.cr","line_number":1,"url":null},{"filename":"src/cligen/command/subcommand.cr","line_number":1,"url":null},{"filename":"src/cligen/command/trigger.cr","line_number":1,"url":null},{"filename":"src/cligen/command_node.cr","line_number":4,"url":null},{"filename":"src/cligen/flag.cr","line_number":3,"url":null},{"filename":"src/cligen/generate.cr","line_number":2,"url":null},{"filename":"src/cligen/match_type.cr","line_number":1,"url":null}],"repository_name":"CliGenerator","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"ADDITIONAL_DEFAULT_FLAGS","name":"ADDITIONAL_DEFAULT_FLAGS","value":"[] of AdditionalDefaultFlag"},{"id":"APPNAME","name":"APPNAME","value":"File.basename(PROGRAM_NAME)"},{"id":"VERSION","name":"VERSION","value":"\"0.1.0\""}],"class_methods":[{"html_id":"add_default_flag(short:String=\"\",long:String=\"\",description:String=\"\",&work:String->)-class-method","name":"add_default_flag","abstract":false,"args":[{"name":"short","default_value":"\"\"","external_name":"short","restriction":"String"},{"name":"long","default_value":"\"\"","external_name":"long","restriction":"String"},{"name":"description","default_value":"\"\"","external_name":"description","restriction":"String"}],"args_string":"(short : String = \"\", long : String = \"\", description : String = \"\", &work : String -> )","args_html":"(short : String = <span class=\"s\">&quot;&quot;</span>, long : String = <span class=\"s\">&quot;&quot;</span>, description : String = <span class=\"s\">&quot;&quot;</span>, &work : String -> )","location":{"filename":"src/cligen.cr","line_number":23,"url":null},"def":{"name":"add_default_flag","args":[{"name":"short","default_value":"\"\"","external_name":"short","restriction":"String"},{"name":"long","default_value":"\"\"","external_name":"long","restriction":"String"},{"name":"description","default_value":"\"\"","external_name":"description","restriction":"String"}],"yields":1,"block_arity":1,"block_arg":{"name":"work","external_name":"work","restriction":"(String ->)"},"visibility":"Public","body":"if description.empty?\n raise(\"ERROR : add_default_flag : You must provide a description\")\nend\nADDITIONAL_DEFAULT_FLAGS << AdditionalDefaultFlag.new(short: short, long: long, description: description, work: work)\n"},"external_var":false}],"types":[{"html_id":"CliGenerator/CliGen/AdditionalDefaultFlag","path":"CliGen/AdditionalDefaultFlag.html","kind":"struct","full_name":"CliGen::AdditionalDefaultFlag","name":"AdditionalDefaultFlag","abstract":false,"superclass":{"html_id":"CliGenerator/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"CliGenerator/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"CliGenerator/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"CliGenerator/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/cligen.cr","line_number":15,"url":null}],"repository_name":"CliGenerator","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"CliGenerator/CliGen","kind":"module","full_name":"CliGen","name":"CliGen"},"constructors":[{"html_id":"new(short:String,long:String,description:String,work:String->)-class-method","name":"new","abstract":false,"args":[{"name":"short","external_name":"short","restriction":"String"},{"name":"long","external_name":"long","restriction":"String"},{"name":"description","external_name":"description","restriction":"String"},{"name":"work","external_name":"work","restriction":"(String -Line truncated
Symlink
+1
View File
@@ -0,0 +1 @@
..
+2 -2
View File
@@ -2,8 +2,8 @@ name: cligen
version: 0.1.0
authors:
- Tristan Ancelet <tristan.ancelet@acumera.com>
- Tristan Ancelet <tristanancelet@yahoo.com>
crystal: '>= 1.19.1'
license: MIT
license: Apache-2.0
+93
View File
@@ -0,0 +1,93 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
require "../spec_helper"
def make_arg(val, index = 0) : CliGen::Arg
CliGen::Arg.new(value: val, index: index)
end
describe CliGen::Arg do
describe "#processed" do
it "will raise a ArgReprocessedError exception when re-processed" do
arg = make_arg("abc")
arg.processed
expect_raises(CliGen::ArgReprocessedError) do
arg.processed
end
end
end
describe "#flag?" do
it "will return true when value is in long flag format --[a-zA-Z0-9-_]+" do
arg = make_arg("--help")
arg.flag?.should be_true
end
it "will return true when value is in short flag format -[a-zA-Z0-9]" do
arg = make_arg("-h")
arg.flag?.should be_true
end
it "will return false when value is literally anything else" do
arg = make_arg("abc")
arg.flag?.should be_false
end
end
describe "#uint?" do
it "will return true on a value in an unigned int format ^[[:digit:]]+$" do
make_arg("3").uint?.should be_true
end
it "will return false on a value in an signed int format ^[+-][[:digit:]]+$" do
make_arg("-3").uint?.should be_false
make_arg("+3").uint?.should be_false
end
it "will return false on a value in a mixed format" do
make_arg("a2").uint?.should be_false
end
it "will return false on a value in any other format" do
make_arg("a").uint?.should be_false
end
end
describe "#int?" do
it "will return true on a value in int format ^[[:digit:]]+$" do
make_arg("3").int?.should be_true
end
it "will return true on a value in an signed int format ^[+-][[:digit:]]+$" do
make_arg("-3").int?.should be_true
make_arg("+3").int?.should be_true
end
it "will return false on a value in a mixed format" do
make_arg("a2").int?.should be_false
end
it "will return false on a value in any other format" do
make_arg("a").int?.should be_false
end
end
describe "#float?" do
it "will return true on a value in a float format ^[[:digit:]]+\.[[:digit:]]+$" do
make_arg("1.1").float?.should be_true
end
it "will return true on a value in a int format ^[[:digit:]]$" do
make_arg("1").float?.should be_true
end
it "will return false on a value in any other format" do
make_arg("a").float?.should be_false
end
it "will return false on a value that isn't fully int's" do
make_arg("a1").float?.should be_false
end
end
end
+437
View File
@@ -0,0 +1,437 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
require "../spec_helper"
module CliGen
class Flag(T)
def test_coerce(var : String)
coerce(var)
end
def process(args : Array(String))
process(make_args(args))
end
end
end
enum TestEnum
ABC
DEF
GHI
end
class MyGoodData
extend CliGen::Coercable
extend CliGen::Parsable
getter value : TestEnum
def initialize(@value)
end
def self.to_s
nil
end
def to_s
@value.to_s
end
def to_s(io : IO)
io << @value.to_s
end
def self.coerce(arg : String)
case arg
when "abc"
new(TestEnum::ABC)
when "def"
new(TestEnum::DEF)
when "ghi"
new(TestEnum::GHI)
else
raise "WTF?"
end
end
def self.parse_args(args : Array(CliGen::Arg))
raise "ERROR" if args.empty?
arg = args.first
arg.processed
coerce(arg.value)
end
end
class MyBadData < MyGoodData
def self.parse_args(args : Array(CliGen::Arg))
raise "ERROR" if args.empty?
arg = args.first
coerce(arg.value)
end
end
def make_arg(value, index : Int32 = 0) : CliGen::Arg
CliGen::Arg.new(value: value, index: index)
end
def make_args(values : Array(String)) : Array(CliGen::Arg)
output = [] of CliGen::Arg
values.each_with_index{|v, i| output << make_arg(v,i)}
output
end
macro make_flag(type, long = "--test", env_var = "TEST", var = "", description = "", short = nil, delimiter = ",", default = nil, options = nil, validate = nil, on_match = nil, format = nil)
CliGen::Flag({{type}}).new(
var: {{var}},
env_var: {{env_var}},
short: {{short}},
long: {{long}},
description: {{description}},
delimiter: {{delimiter}},
default: {{default}},
options: {{options}},
validate: {{validate}},
on_match: {{on_match}},
format: {{format}}
)
end
describe CliGen::Flag do
before_each { ENV.delete("TEST") }
describe "#check!" do
it "will throw CliGen::ReservedFlagError if -h is used as short" do
expect_raises(CliGen::ReservedFlagError) do
make_flag(type: Bool, short: "-h", long: "--not-help").check!
end
end
it "will throw CliGen::ReservedFlagError if --help is used in long" do
expect_raises(CliGen::ReservedFlagError) do
make_flag(type: Bool, short: "-b", long: "--help TOPIC").check!
end
end
it "will throw CliGen::ReservedFlagError if --help is used as long_key" do
expect_raises(CliGen::ReservedFlagError) do
make_flag(type: Bool, short: "-b", long: "--help").check!
end
end
end
describe "#value!" do
it "will throw CliGen::MissingRequiredFlagError if a flag without a default value is called with no way of determining a value" do
flg = make_flag(type: String)
expect_raises(CliGen::MissingRequiredFlagError) do
flg.value!
end
end
it "will fallback to provided default if no data is provided by the user" do
make_flag(type: String, default: "abc").value!.should eq "abc"
end
it "will resolve values from ENV VAR if not directly supplied with one" do
flg = make_flag(type: String, env_var: "MYTESTVAR")
ENV["MYTESTVAR"] = "abc"
flg.value!.should eq "abc"
end
describe "Flag(Array(String))" do
it "returns a valid array when resolving from ENV VAR" do
flg = make_flag(type: Array(String), env_var: "ABCDEF")
ENV["ABCDEF"]="a,b,c"
flg.value!.should eq %w[ a b c ]
end
end
end
describe "#coerce" do
{% for int in Int.subclasses %}
{% uint = int.stringify =~ /^UInt/ ? true : false %}
describe "Flag({{int}})" do
it "can correctly coerce {{int}}" do
make_flag(type: {{int}}).test_coerce("1").should be_a {{int}}
end
it "will raise CliGen::InvalidFlagValueError if provided a value that is not an {{int}}" do
expect_raises(CliGen::InvalidFlagValueError) do
make_flag(type: {{int}}).test_coerce("abc")
end
end
{% if uint %}
it "will raise CliGen::InvalidFlagValueError if provided a value in a signed int" do
expect_raises(CliGen::InvalidFlagValueError) do
make_flag(type: {{int}}).test_coerce("-1")
end
end
{% end %}
end
{% if uint %}
describe "Flag(Array({{int}}))" do
it "Will be correctly parsed when providing an unsigned int" do
abc = "1,2,3"
make_flag(type: Array({{int}})).test_coerce(abc).should eq([ 1, 2, 3 ] of {{int}})
end
it "will raise CliGen::InvalidFlagValueError if an signed int is provided" do
abc = "-1,2,3"
expect_raises(CliGen::InvalidFlagValueError) do
make_flag(type: Array({{int}})).test_coerce(abc)
end
end
end
{% else %}
describe "Flag(Array({{int}}))" do
it "Will be correctly parsed when providing a signed int" do
abc = "-1,2,3"
make_flag(type: Array({{int}})).test_coerce(abc).should eq([ -1, 2, 3 ] of {{int}})
end
end
{% end %}
{% end %}
{% for float in Float.subclasses %}
describe "Flag({{float}})" do
it "can correctly coerce {{float}}" do
make_flag(type: {{float}}).test_coerce("1.1").should be_a {{float}}
end
it "will raise CliGen::InvalidFlagValueError if provided value isn't a {{float}}" do
expect_raises(CliGen::InvalidFlagValueError) do
make_flag(type: {{float}}).test_coerce("why")
end
end
end
describe "Flag(Array({{float}}))" do
it "will correctly coerce data in a unsigned int format" do
abc = "1,2,3"
make_flag(type: Array({{float}})).test_coerce(abc).should eq([1,2,3] of {{float}})
end
it "will correctly coerce data in a signed int format" do
abc = "-1,2,3"
make_flag(type: Array({{float}})).test_coerce(abc).should eq([-1,2,3] of {{float}})
end
it "will correctly coerce data in a mixed int & float format" do
abc = "-1,2,3.2"
make_flag(type: Array({{float}})).test_coerce(abc).should eq([-1,2,3.2] of {{float}})
end
end
{% end %}
describe "Flag(Bool)" do
it "correctly coerces with valid data" do
%w[ t true 1 y yes ].each do |opt|
make_flag(type: Bool).test_coerce(opt).should be_true
end
%w[ f false 0 n no ].each do |opt|
make_flag(type: Bool).test_coerce(opt).should be_false
end
end
it "raises CliGen::InvalidFlagValueError if provided an invalid value" do
expect_raises(CliGen::InvalidFlagValueError) do
make_flag(type: Bool).test_coerce("why?")
end
end
end
describe "Flag(Array(CustomObj))" do
it "can correctly coerce data from the custom object" do
flg = make_flag(type: Array(MyGoodData))
flg.test_coerce("abc,def").map(&.to_s.downcase).should eq %w[ abc def ]
end
end
describe "Flag(Array(String))" do
it "correctly splits based on delimiter" do
flg = make_flag(type: Array(String), long: "--mytest", delimiter: "|")
flg.test_coerce("a|b|c").should eq %w[ a b c ]
end
it "will raise CliGen::InvalidFlagValueError if an element of the array doesn't match the format defined" do
flg = make_flag(type: Array(String), format: /^test[A-Z]$/)
expect_raises(CliGen::InvalidFlagValueError) do
flg.test_coerce("testA,testB,test1")
end
end
end
end
describe "#validate!" do
it "will raise CliGen::InvalidOptionError if the provided value isn't in the static list of options" do
flg = make_flag(type: String, long: "--test", env_var: "TESTVAR", options: %w[ a b c ])
ENV["TESTVAR"] = "d"
expect_raises(CliGen::InvalidOptionError) do
flg.validate!
end
end
it "will raise CliGen::ValidationError if the dev provided validation fails" do
flg = make_flag(type: String, long: "--test", env_var: "TESTVAR", validate: ->(v : String) : Bool { v == "abc" })
ENV["TESTVAR"] = "def"
expect_raises(CliGen::ValidationError) do
flg.validate!
end
end
describe "Flag(Array(String))" do
flg = make_flag(type: Array(String), long: "--test", env_var: "TESTVAR2", options: [%w[ a b c ]])
it "will raise CliGen::InvalidOptionError if the provided value isn't in the static list of options" do
end
end
end
describe "#process" do
describe "Flag(String)" do
it "will raise CliGen::InvalidFlagValueError if provided string doesn't match format" do
flg = make_flag(type: String, env_var: "TEST", short: "-t", long: "--test", format: /^abc$/)
expect_raises(CliGen::InvalidFlagValueError) do
flg.process(%w[ def ])
end
end
end
{% for int in Int.subclasses %}
{% uint = int.stringify =~ /^UInt/ ? true : false %}
describe "Flag({{int}})" do
it "coerces a valid {{int}} from provided arguments" do
{% if uint %}
val = 1
{% else %}
val = -1
{% end %}
flg = make_flag(type: {{int}})
flg.process(make_args([val.to_s]))
flg.value!.should eq val
end
{% if uint %}
it "will raise CliGen::InvalidFlagValueError if provided a signed int" do
expect_raises(CliGen::InvalidFlagValueError) do
make_flag(type: {{int}}).process([make_arg("-1", 0)])
end
end
{% end %}
end
describe "Flag(Array({{int}}))" do
{% if uint %}
it "will raise when a signed int is provided" do
args = make_args(%w[ 1 2 -3 ])
flg = make_flag(type: Array({{int}}))
expect_raises(CliGen::InvalidFlagValueError) do
flg.process(args)
end
end
it "will raise when a signed int is provided in a delimited string" do
args = [make_arg("1,2,-3")]
flg = make_flag(type: Array({{int}}))
expect_raises(CliGen::InvalidFlagValueError) do
flg.process(args)
end
end
{% end %}
it "can consume positive ints" do
args = make_args(%w[ 1 2 3 ])
flg = make_flag(type: Array({{int}}))
flg.process(args)
flg.value!.should eq([1, 2, 3] of {{int}})
end
it "can consume positive ints in a delimited string" do
args = [make_arg("1,2,3", 0)]
flg = make_flag(type: Array({{int}}))
flg.process(args)
flg.value!.should eq([1, 2, 3] of {{int}})
end
it "can consume positive ints in a delimited string and will strip whitespace" do
args = [make_arg("1 ,2,3", 0)]
flg = make_flag(type: Array({{int}}))
flg.process(args)
flg.value!.should eq([1, 2, 3] of {{int}})
end
it "can consume positive ints in multiple arguments" do
args = make_args(%w[ 1,2,3 4 ])
flg = make_flag(type: Array({{int}}))
flg.process(args)
flg.value!.should eq([1, 2, 3, 4] of {{int}})
end
{% unless uint %}
it "can consume signed ints" do
args = make_args(%w[ 1 2 -3 ])
flg = make_flag(type: Array({{int}}))
flg.process(args)
flg.value!.should eq([1, 2, -3] of {{int}})
end
it "can consume signed ints in a delimited string" do
args = [make_arg("1,2,-3")]
flg = make_flag(type: Array({{int}}))
flg.process(args)
flg.value!.should eq([1, 2, -3] of {{int}})
end
{% end %}
end
{% end %}
{% for float in Float.subclasses %}
describe "Flag({{float}})" do
it "coerces a valid {{float}} from provided arguments" do
val = {{float}}.new("1.1")
flg = make_flag(type: {{float}})
flg.process(make_args([val.to_s]))
flg.value!.should eq val
end
end
describe "Flag(Array({{float}}))" do
it "can handle an array of int/float formatted values" do
args = make_args(%w[ 1 2 3 1.1 -1])
flg = make_flag(type: Array({{float}}))
flg.process(args)
flg.value!.should eq([1, 2, 3, 1.1, -1] of {{float}})
end
end
{% end %}
describe "Flag(Array(String))" do
it "will throw CliGen::InvalidFlagValueError if a deserialized var/item is an invalid format" do
flg = make_flag(type: Array(String), format: /^(a|b|c)$/)
expect_raises(CliGen::InvalidFlagValueError) do
flg.process([ "a,b,c,d" ])
end
end
end
describe "Flag(CustomObj)" do
it "will throw a CliGen::ParseableInvariantError if object doesn't mark data as processed" do
flg = make_flag(type: MyBadData)
expect_raises(CliGen::ParseableInvariantError) do
flg.process(["abc"])
end
end
it "will correctly set the value if parsed" do
flg = make_flag(type: MyGoodData)
flg.process(["abc"])
flg.value!.value.should eq TestEnum::ABC
end
end
end
end
-131
View File
@@ -1,131 +0,0 @@
require "spec"
require "../src/command"
@[CliGen::CommandInfo(description: "Test")]
class CommandSubclass < CliGen::Command
define_argument(testvar,
type: Int32,
long: "--testvar TESTVAR",
description: "Does things"
)
define_argument(testvar_the_return,
type: Int32,
def_getter: true,
long: "--testvar_the_return TESTVAR",
description: "Does things"
)
end
EXAMPLES = [
"Have test"
]
@[CliGen::SubCommand(description: "test", examples: ::EXAMPLES)]
def CommandSubclass.do_thing
puts "HI"
end
@[CliGen::CommandPreRun]
def CommandSubclass.check_things
puts "I was run"
end
## Need to make sure EVERYTHING is generated before testing
macro finished
describe CliGen::Command do
describe "subclassing" do
describe "Creates the arguments" do
it "has testvar" do
{{CommandSubclass.class.has_method?(:testvar)}}.should be_true
end
it "has testvar2 getter" do
{{CommandSubclass.class.has_method?(:get_testvar_the_return)}}.should be_true
end
end
it "has Header" do
CommandSubclass::HEADER.empty?.should be_false
end
it "has examples" do
CommandSubclass::HEADER.includes?("Examples").should be_true
end
{% pre_runs = CommandSubclass.class.methods.select(&.annotation(::CliGen::CommandPreRun)) %}
{% run = CommandSubclass.class.methods.find{|m| m.name.stringify == "run"}.stringify %}
{% if pre_runs.size > 0 %}
describe "when defining pre-run methods" do
{% for pre_run in pre_runs %}
it "generates {{pre_run.name}}" do
{{run}}.includes?({{pre_run.name.stringify}}).should be_true
end
{% end %}
end
{% end %}
{% subcommands = CommandSubclass.class.methods.select(&.annotation(::CliGen::SubCommand)) %}
{% unless subcommands.empty? %}
describe "should have subcommands" do
{% for subcommand in subcommands %}
it "has {{subcommand.name}}" do
{{CommandSubclass.class.has_method?(subcommand.name.symbolize)}}.should be_true
end
{% end %}
end
{% end %}
{% arguments = CommandSubclass.class.methods.select(&.annotation(::CliGen::CommandArgument)) %}
{% unless arguments.empty? %}
describe "should have arguments" do
{% for argument in arguments %}
it "has {{argument.name}}" do
{{CommandSubclass.class.has_method?(argument.name.symbolize)}}.should be_true
end
{% end %}
end
{% end %}
{% if [arguments, subcommands].any?{|i| i.size >= 0 } %}
describe "should have generated OptionParser parser.on" do
{{ make_parser = CommandSubclass.class.methods.find{|m| m.name.stringify == "make_parser"}.stringify}}
{% unless subcommands.empty? %}
describe "for subcommands" do
{% for command in subcommands %}
it "has {{command.name}}" do
{{make_parser}}.includes?("on(" + {{command.name.stringify.stringify}}).should be_true
end
{% end %}
end
{% end %}
{% unless arguments.empty? %}
describe "for arguments" do
{% for argument in arguments %}
{% anno = argument.annotation(::CliGen::CommandArgument) %}
it "has " + {{anno[:long].stringify}} do
{{make_parser}}.includes?({{anno[:long]}}).should be_true
end
{% end %}
end
{% end %}
end
{% end %}
describe "Should have generated macro class methods" do
it "has generated run" do
{{CommandSubclass.class.has_method?(:run)}}.should be_true
end
it "has generated make_parser" do
{{CommandSubclass.class.has_method?(:make_parser)}}.should be_true
end
end
end
end
end
+6
View File
@@ -0,0 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
require "spec"
require "../src/cligen"
+16 -93
View File
@@ -1,103 +1,26 @@
require "option_parser"
require "./cligen/regex"
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
require "./cligen/exceptions"
require "./cligen/coercable"
require "./cligen/parsable"
require "./cligen/annotations"
require "./cligen/format"
require "./cligen/regex"
require "./cligen/flag"
require "./cligen/timeparse"
require "./cligen/command"
require "./cligen/command_node"
require "./cligen/app"
module CliGen
VERSION = "0.1.0"
APPNAME = File.basename(PROGRAM_NAME)
record AdditionalDefaultFlag,
short : String,
long : String,
description : String,
work : String ->
ADDITIONAL_DEFAULT_FLAGS = [] of AdditionalDefaultFlag
def self.add_default_flag(short : String = "", long : String = "", description : String = "", &work : String -> )
raise "ERROR : add_default_flag : You must provide a description" if description.empty?
ADDITIONAL_DEFAULT_FLAGS << AdditionalDefaultFlag.new(
short: short,
long: long,
description: description,
work: work
)
end
annotation DefaultFlag
end
macro define_section(section_name, parser)
{{parser}}.separator ""
{{parser}}.separator "{{section_name.id}}".colorize(:green)
{{parser}}.separator "-------------------------------------------------------------------------------".colorize(:blue)
end
alias OnType = Tuple(String, String) | Tuple(String, String, String)
macro define_default_flags(parser)
CliGen.define_section("Misc Flags", {{parser}})
{{parser}}.on("-h", "--help", "Print out this help output"){ abort {{parser}} }
{{parser}}.invalid_option{|opt|
abort "#{CliGen::APPNAME} : invalid_option : Inavlid option provided #{opt}"
}
{{parser}}.invalid_option{|opt|
case opt
when /^-+[a-z-]+/
STDERR.puts "#{CliGen::APPNAME} : ERROR : {{@type.name}} : {{parser}} : invalid_option : Inavlid option provided #{opt}"
else
abort "#{CliGen::APPNAME} : ERROR : {{@type.name}} : {{parser}} : invalid_option : Inavlid option provided #{opt}"
end
}
{{parser}}.missing_option{|opt|
abort "ERROR : {{@type.name}} : {{parser}} : missing_option : Argument was not provided to #{opt}"
}
{{parser}}.unknown_args{|opt|
unless opt.empty?
case opt.first
when /^-+[a-z-]+$/
STDERR.puts "ERROR : {{@type.name}} : {{parser}} : unknown_args : #{opt} not a configured argument"
else
abort "ERROR : {{@type.name}} : {{parser}} : unknown_args : #{opt} not a configured argument"
end
end
}
CliGen::ADDITIONAL_DEFAULT_FLAGS.each do |flag|
if [ flag.short, flag.long ].all?(&.!= "")
{{parser}}.on(flag.short, flag.long, flag.description){|var| flag.work.call(var) }
elsif flag.short != ""
{{parser}}.on(flag.short, flag.description){|var| flag.work.call(var) }
elsif flag.long != ""
{{parser}}.on(flag.long, flag.description){|var| flag.work.call(var) }
end
end
end
macro define_root_parser
ROOT_COMMAND = OptionParser.new do |parser|
parser.banner = "#{CliGen::APPNAME} [command] [flags]"
{% commands = ::CliGen::Command.subclasses %}
{% raise "ERROR : No commands defined (no subclasses of ::CliGen::Command were found)" if commands.empty? %}
CliGen.define_section("Commands", parser)
{% for command in commands %}
{{command.name}}.make_parser(parser)
{% end %}
CliGen.define_default_flags(parser)
abort parser if ARGV.empty?
macro override_help_template(filepath)
{% raise "ERROR : CliGen.override_help_template : File(#{filepath}) doesn't exist" unless file_exists?(filepath) %}
CliGen::HELP_OVERRIDE_TEMPLATE = {{`readlink -f #{filepath}`.strip.stringify}}
end
end
macro finished
define_root_parser
end
def self.parse
ROOT_COMMAND.parse
end
end
require "./cligen/command"
+25
View File
@@ -0,0 +1,25 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
module CliGen
annotation ProxyCommand
end
annotation CommandInfo
end
annotation Argument
end
annotation Trigger
end
annotation Selection
end
annotation PreRunCommand
end
annotation SubCommand
end
end
+79
View File
@@ -0,0 +1,79 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
require "./arg"
require "./command_node"
require "./flag"
require "./app/generate"
module CliGen
# Root entry point. Holds a flattened copy of all flags from every command
# for global-flag matching, then hands off to the matched child CommandNode.
class App < CliGen::CommandNode(Nil)
@@instance : self?
def initialize(@name, flags : Array(BaseFlag), commands : Array(BaseCommandNode), pre_run_commands : Array(RunCommand), post_run_commands : Array(RunCommand))
super(name: @name, flags: flags, commands: commands, pre_run_commands: pre_run_commands, post_run_commands: post_run_commands)
@@instance = self
end
def check!
super
check_for_env_duplicates(all_flags + CliGen::GLOBAL_FLAGS)
end
def check_for_env_duplicates(flags : Array(BaseFlag))
flgs = flags.reject(&.env_var.empty?)
env_vars = flgs.group_by(&.env_var)
failures = [] of Tuple(String, Array(BaseFlag))
env_vars.each do |env_var, flg_group|
if flg_group.size > 1
failures << Tuple.new(env_var, flg_group)
end
end
unless failures.empty?
error_buffer = "ERROR : App(%s)#check! : Found ENV VAR Duplicates \n%s"
format = "\n%s:\n%s\n\n"
buffer = ""
failures.each do |env_var, flgs|
buffer += format % [env_var, flgs.map{|f| "- #{f.long_key}"}.join("\n")]
end
raise CliGen::DuplicateFlagError.new(error_buffer % [@name, buffer])
end
end
def self.handle_command_raises(&) : Nil
# doing Fiber.yield to allow Log to print log output before shoving data to screen
begin
# Had to use yeild because doing .call on a provided block had the compiler
# freaking out about not being able to determine a type of a variable in the
# context it was being called from.
yield
rescue e : CliGen::RuntimeError
Fiber.yield
abort e.message
rescue e : CliGen::ConfigurationError
Fiber.yield
abort e.message
rescue e : CliGen::HelpRequestedError
Fiber.yield
puts e.message
exit 0
end
end
# Convenience entry point; defaults to ARGV
def self.process(args : Array(String) = ARGV.to_a) : Nil
generate if @@instance.nil?
handle_command_raises do
@@instance.not_nil!.process(args)
end
end
end
end
+64
View File
@@ -0,0 +1,64 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
module CliGen
macro finished
class App
private def self.generate
app_flags = [] of BaseFlag
app_commands = [] of BaseCommandNode
{% verbatim do %}
{% for cmd in CliGen::Command.subclasses %}
{% cmd_info = cmd.annotation(CliGen::CommandInfo) %}
{% raise "ERROR : CliGen::App.generate : No CliGen::CommandInfo annotation made for #{cmd.name}" unless cmd_info %}
{% raise "ERROR : CliGen::App.generate : Description must be provided for #{cmd.name}" unless cmd_info[:description].is_a? StringLiteral %}
{% cmd_name = cmd.name.split("::").last.downcase %}
{% cmd_flags = cmd.instance_vars.select{|v| v.annotation(CliGen::Argument) || v.annotation(CliGen::Selection) } %}
cmd_flags = [] of BaseFlag
cmd_sub_commands = [] of BaseCommandNode
cmd_pre_run_cmds = [] of Proc(Nil)
cmd_post_run_cmds = [] of Proc(Nil)
{% for var in cmd_flags %}
{% anno = var.annotation(CliGen::Argument) || var.annotation(CliGen::Selection) %}
cmd_flags << Flag({{var.type}}).new(
var: {{ var.name.stringify }},
short: {% if anno[:short] %} {{anno[:short]}} {% else %} nil {% end %},
long: {{ anno[:long] }},
env_var: {% if anno[:env_var] %} {{anno[:env_var]}} {% else %} {{"#{cmd.name.split("::").last.upcase.id}_#{var.name.upcase}"}} {% end %},
description: {{ anno[:description] }},
default: {% unless var.default_value.nil? %} {{var.default_value}} {% else %} nil {% end %},
validate: {% if anno[:validation] %} {{anno[:validation]}} {% else %} nil {% end %},
on_match: {% if anno[:on_match] %} {{anno[:on_match]}} {% else %} nil {% end %},
options: {% if anno[:options] %} {{anno[:options]}} {% else %} nil {% end %},
delimiter: {% if anno[:delimiter] %} {{anno[:delimiter]}} {% else %} "," {% end %},
format: {% if anno[:format] %} {{anno[:format]}} {% else %} nil {% end %}
)
{% debug if env("DEBUG") %}
{% end %}
app_commands << CommandNode({{cmd}}).new(
name: {{cmd_name}},
flags: cmd_flags,
commands: cmd_sub_commands,
pre_run_commands: cmd_pre_run_cmds,
post_run_commands: cmd_post_run_cmds,
description: {{cmd_info[:description]}}
)
{% debug if env("DEBUG") %}
{% end %}
{% end %}
new(
name: File.basename(::PROGRAM_NAME),
flags: app_flags,
commands: app_commands,
pre_run_commands: [] of Proc(Nil),
post_run_commands: [] of Proc(Nil)
)
end
end
end
end
+87
View File
@@ -0,0 +1,87 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
module CliGen
# This class serves as a "argument wrapper" to force a fail-fast approach to
# arg-parsing.
#
# It wraps around the argument + index of the argument to do state tracking
# and ensure that each argument is only processed once (plus allows for
# easier filtering of processed arguments to avoid having to do index math)
#
# args.reject(&.processed?) # returns the args that haven't been processed yet
#
# It expects each argument to only be processed once and will force a raise
# if the argument has Arg#processed called a second time. This is to force
# the developer (me) to fix any processing issues during the development of
# this framework.
class Arg
# The raw string argument provided from the user
getter value : String
# The index of the argument in the array it was in
getter index : Int32
# The "flag"/variable that tracks is the Arg has been processed yet
getter? processed : Bool = false
def initialize(@value, @index)
end
def self.flag?(val : String) : Bool
if val =~ CliGen::Regex::FLAG_REGEX
true
else
false
end
end
def flag?(val : String = @value) : Bool
Arg.flag?(val)
end
def self.int?(val : String) : Bool
if val =~ CliGen::Regex::INT
true
else
false
end
end
def int?(val : String = @value) : Bool
Arg.int?(val)
end
def self.uint?(val : String) : Bool
if val =~ CliGen::Regex::UINT
true
else
false
end
end
def uint?(val : String = @value) : Bool
Arg.uint?(val)
end
def self.float?(val : String) : Bool
if val =~ CliGen::Regex::FLOAT
true
else
false
end
end
def float?(val : String = @value) : Bool
Arg.float?(val)
end
# This serves as a trigger that tells the object that it has been processed
#
# This will raise an exception if it is re-called after already having been
# processed.
def processed
raise CliGen::ArgReprocessedError.new("CliGen::Arg(index: #{@index}, value: #{@value})#processed : This arg was re-processed") if @processed
@processed = true
end
end
end
+6
View File
@@ -0,0 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
module CliGen::Coercable
abstract def coerce(arg : String)
end
+15 -178
View File
@@ -1,193 +1,30 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
require "colorize"
require "time"
require "./command/parser"
require "./annotations"
require "./command/argument"
require "./command/selection"
require "./command/help_template"
require "./command/subcommand"
require "./command/def_init"
require "./command/define_command_initializer"
module CliGen
annotation CommandPreRun
end
annotation CommandInfo
end
annotation CommandArgument
end
annotation CommandSelection
end
annotation SubCommand
end
class Command
extend CliGen::Parser
macro inherited
{% verbatim do %}
macro finished
define_actions
define_header
{% anno = @type.annotation(::CliGen::CommandInfo) %}
{% unless anno[:def_runner] == false %}
define_runner
{% anno = @type.annotation(CliGen::CommandInfo) %}
{% raise "" unless anno %}
{% if anno[:def_init] %}
def_init
{% end %}
define_parser
define_action_setter
end
{% end %}
end
macro define_actions
@@action : String = ""
ACTIONS = {{@type.class.methods.select(&.annotation(::CliGen::SubCommand)).map(&.name.stringify)}} of String
end
macro define_header
{% name = @type.name.split("::").last.downcase.id %}
{% info_annos = @type.class.methods.select(&.annotation(::CliGen::SubCommand)).map(&.annotation(::CliGen::SubCommand)) %}
{% info_annos += @type.class.methods.select(&.annotation(::CliGen::CommandSelection)).map(&.annotation(::CliGen::CommandSelection)) %}
{% examples = [] of StringLiteral %}
{% info_annos.select(&.[](:examples)).map(&.[](:examples).resolve).each(&.each{|example| examples << example}) %}
HEADER = [
"#{CliGen::APPNAME} {{name}} [[flags]]",
"",
{% unless examples.empty? %}
"Examples:".colorize(:green),
"-------------------------------------------------------------------------------".colorize(:blue),
{% for example in examples %}
{{example}},
{% end %}
{% end %}
].join("\n")
end
macro define_selection(selection_name, short = "", long = "", description = nil, default = "", values = [] of StringLiteral)
{% if values.is_a? Path %}
{% values = values.resolve %}
{% end %}
{% raise "ERROR : define_selection : You MUST provide a description" unless description %}
{% raise "ERROR : define_selection : You must provide a valid set of values in Array(String) format" if values.empty? %}
{% description = "#{description.id} (valid: #{values.join(", ").id})" %}
{% unless default.empty? %}
{% description = "#{description.id} (default: #{default.id})" %}
{% end %}
@@{{selection_name}} : String = {{default}}
@[::CliGen::CommandArgument(short: {{short}}, long: {{long}}, description: {{description}} )]
def self.{{selection_name}}= (selection : String)
raise "ERROR : {{selection_name}} : Invalid Selection(#{selection}) (valid: {{values.map(&.id).join(", ").id}})" unless {{values}}.includes?(selection)
@@{{selection_name}} = selection
end
end
macro define_argument(arg_name, variable = nil, type = String, short = "", long = "", description = nil, subtype = Nil, format = nil, check = nil, def_getter = false, default = nil, logger = nil, &block?)
{% raise "ERROR : define_argument : You must provide a format or set it to \"auto\" to use builtin formats when defining a Time argument" if type.id.stringify == "Time" && format == nil %}
{% raise "ERROR : define_argument : You MUST provide a description" unless description %}
{% variable = arg_name unless variable %}
{% _type = type.id.stringify %}
{% _subtype = subtype.id.stringify %}
{% if _type == "String" %}
@@{{variable}} : {{type}} = ""
{% elsif _type == "Bool" %}
@@{{variable}} : {{type}} = false
{% elsif _type == "Int32" %}
@@{{variable}} : {{type}} = 0
{% elsif _type == "Array" %}
{% raise "define_argument : subtype can only be Int32 or String" unless %w[ Int32 String ].includes?(_subtype) %}
@@{{variable}} : {{type}}({{subtype}}) = [] of {{subtype}}
{% elsif _type == "Time" %}
@@{{variable}} : {{type}} = Time.unix(seconds: 0)
{% end %}
{% if def_getter %}
def self.get_{{arg_name}} : {{type}}
@@{{variable}}
end
{% end %}
@[::CliGen::CommandArgument(type: {{type}}, short: {{short}}, long: {{long}}, description: {{description}})]
def self.{{arg_name}}(var : String) : Nil
{% if check %}
## If the check exists go ahead and call it
{{check}}(var)
{% end %}
## If a logger method has been provided by the user
{% if logger %}
{{logger.id}} "Command : subclass : argument_setter : {{arg_name}} : Entered with #{var}"
{% end %}
{% if _type == "Time" %}
formats = [
CliGen::Regex::INPUT_DATETIME_REGEX,
CliGen::Regex::INPUT_DATE_REGEX
]
abort "ERROR : Command : {{arg_name}} : Incorrect format for provided data #{var}" unless formats.any?{|f| var.match(f)}
if var =~ formats[0]
@@{{variable}} = Time.parse_local(var, CliGen::Format::INPUT_DATETIME_FORMAT)
elsif var =~ formats[1]
@@{{variable}} = Time.parse_local(var, CliGen::Format::INPUT_DATE_FORMAT)
end
{% elsif _type == "Array" %}
{% if _subtype == "Int32" %}
var : Int32 = var.to_i
{% elsif _subtype == "String" %}
{% else %}
var = {{subtype}}.new(var)
{% end %}
@@{{variable}} << var
{% elsif _type == "Bool" %}
@@{{variable}} = true
{% elsif _type == "Int32" %}
@@{{variable}} = var.to_i
{% elsif _type == "String" %}
@@{{variable}} = var
{% end %}
end
end
macro define_runner
def self.run
{% pre_run_commands = @type.class.methods.select(&.annotation(::CliGen::CommandPreRun)) %}
{% unless pre_run_commands.empty? %}
## Ensuring that all runs that are tagged with the the CommandPreRun annotation are run
{% for method in pre_run_commands %}
{{method.name}}
{% end %}
{% end %}
{% selections = @type.class.methods.select(&.annotation(::CliGen::CommandSelection)) %}
{% methods = @type.class.methods.select(&.annotation(::CliGen::SubCommand)) %}
{% raise "ERROR : No commands or selections defined for #{@type.name}" if methods.empty? && selections.empty? %}
{% raise "ERROR : Can't define both selections and commands for work in #{@type.name}" if ! methods.empty? && ! selections.empty? %}
{% var = methods.empty? ? nil : "action" %}
{% targets = methods.empty? ? selections : methods %}
{% if targets == selections %}
{% selectors = selections.map(&.annotation(::CliGen::CommandSelection)).map(&.[:selector]).uniq %}
{% raise "ERROR : Can't provide more than a single selector for runner" if selectors.size > 1 %}
{% var = selectors.first %}
{% end %}
{% begin %}
case @@{{var.id}}
{% for target in targets %}
when {{target.name.stringify}}
{{target.name}}
{% end %}
else
abort "ERROR : No action provided to command {{@type.name}}"
define_command_initializer
end
{% end %}
end
end
macro define_action_setter
def self.action=(action : String)
abort "ERROR : Action(#{action}) is not valid. Only #{ACTIONS.join(", ")} are acceptable" unless ACTIONS.includes?(action)
@@action = action
end
end
end
end
+89
View File
@@ -0,0 +1,89 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
module CliGen
class Command
macro argument(variable, description, long = nil, short = nil, validation = nil, on_match = nil, def_setter = false, def_getter = false, options = nil, delimiter = ",", format = nil, allow_no_verification = false, env_var = nil)
{% raise "ERROR : CliGen::Command.argument : def_setter must be a Bool" unless def_setter.is_a? BoolLiteral %}
{% raise "ERROR : CliGen::Command.argument : First argument (#{variable}) must be a TypeDeclaration (ex: '<var> : <type> [= val]')" unless variable.is_a? TypeDeclaration %}
{% name = variable.var %}
{% type = variable.type %}
{% if env_var %}
{% raise "ERROR : CliGen::Command.argument(#{name}) : Provided env_var must be a string" unless env_var.is_a? StringLiteral %}
{% raise "ERROR : CliGen::Command.argument(#{name}) : Provided env_var cannot contain a \"-\". Please fix and re-run" if env_var.includes?("-") %}
{% end %}
{% raise "ERROR : CliGen::Command.argument(#{name}) : Provided delimiter must be a string" unless delimiter.is_a? StringLiteral %}
{% if short %}
{% raise "ERROR : CliGen::Command.argument(#{name}) : Provided short must be a string" unless short.is_a? StringLiteral %}
{% end %}
{% if long %}
{% raise "ERROR : CliGen::Command.argument(#{name}) : Provided long must be a string" unless long.is_a? StringLiteral %}
{% raise "ERROR : CliGen::Command.argument(#{name}) : Provided long must match --[a-zA-Z0-9-_]+" unless long =~ /^--[a-zA-Z0-9-_]+/ %}
{% else %}
{% long = "--#{name.downcase}" %}
{% end %}
{% raise "ERROR : CliGen::Command.argument(#{name}) : You must provide a description" unless description %}
{% raise "ERROR : CliGen::Command.argument(#{name}) : Provided description must be a String" unless description.is_a? StringLiteral || description.is_a? StringInterpolation %}
{% unless on_match.nil? %}
{% puts "DEBUG : #{@type.name}.argument(#{name}) : OnMatch:\n\tid: #{on_match}\n\treturn_type: #{on_match.return_type}\n\tinput_vars: #{on_match.args}" if env("DEBUG")%}
{% raise "ERROR : CliGen::Command.argument(#{name}) : Provided on_match must be a Proc" unless on_match.is_a? ProcLiteral %}
{% raise "ERROR : CliGen::Command.argument(#{name}) : You must have arguments for on_match" if on_match.args.empty? %}
{% raise "ERROR : CliGen::Command.argument(#{name}) : Your input argument must have a type" unless on_match.args.first.restriction %}
{% raise "ERROR : CliGen::Command.argument(#{name}) : Your input argument must be the same type as your argument (#{type})" unless on_match.args.first.restriction == type %}
{% end %}
{% unless validation.nil? %}
{% puts "DEBUG : #{@type.name}.argument(#{name}) : Validation:\n\tid: #{validation}\n\treturn_type: #{validation.return_type}\n\tinput_vars: #{validation.args}" if env("DEBUG")%}
{% raise "ERROR : CliGen::Command.argument(#{name}) : Provided validation must be a Proc" unless validation.is_a? ProcLiteral %}
{% raise "ERROR : CliGen::Command.argument(#{name}) : Provided validation return type must be a Bool" unless validation.return_type.resolve == Bool %}
{% raise "ERROR : CliGen::Command.argument(#{name}) : Provided validation provided validation must have an input variable" if validation.args.empty? %}
{% arg = validation.args.first %}
{% unless arg.restriction == type %}
{% example = "->(#{arg.name} : #{type}) : Bool { #{validation.body} }" %}
{% raise "ERROR : CliGen::Command.argument(#{name}) : Provided validation input value must be #{type}. EX: #{example}" %}
{% end %}
{% end %}
{% if options %}
{% options = options.resolve if options.is_a? Path %}
{% if options.is_a? Call %}
{% elsif options.is_a? ArrayLiteral %}
{% else %}
{% raise "ERROR : CliGen::Command.argument(#{name}) : Provided options must be an ArrayLiteral or a runtime method call to retrieve data" %}
{% end %}
{% end %}
{% if format %}
{% format = format.resolve if format.is_a? Path %}
{% raise "ERROR : CliGen::Command.argument(#{name}) : Provided format must be a RegexLiteral" unless format.is_a? RegexLiteral %}
{% end %}
{% if type.resolve <= Array && ! allow_no_verification %}
{% elem = type.resolve.type_vars.first %}
{% unless elem < Int || elem < Float %}
{% if format.nil? && options.nil? %}
{% raise "ERROR : CliGen::Command.argument(#{name}) : When providing custom data types for Array(T) or using Array(String) you must provide a format or options for argument filtering so that parsing can be done deterministically" %}
{% end %}
{% end %}
{% end %}
{% if type.resolve < Array && ! options.nil? %}
@[CliGen::Argument(short: {{short}}, long: {{long}}, description: {{description}}, validation: {{validation}}, on_match: {{on_match}}, options: [{{options}}], delimiter: {{delimiter}}, format: {{format}}, env_var: {{env_var}})]
{% else %}
@[CliGen::Argument(short: {{short}}, long: {{long}}, description: {{description}}, validation: {{validation}}, on_match: {{on_match}}, options: {{options}}, delimiter: {{delimiter}}, format: {{format}}, env_var: {{env_var}})]
{% end %}
@{{variable}}
{% if def_getter %}
def {{variable.var}}
@{{name}}
end
{% end %}
{% if def_setter %}
def {{variable.var}}= (value : {{type}})
{% unless validation.nil? %}
raise CliGen::ValidationError.new("#{@type.name}##{@def.name} : Provided value #{value} failed validation") unless {{validation}}.call(value)
{% end %}
@{{name}} = value
end
{% end %}
end
end
end
+25
View File
@@ -0,0 +1,25 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
module CliGen
class Command
macro def_init
def initialize
{% verbatim do %}
{% for var in @type.instance_vars %}
{% raise "ERROR : Can't define a default initializer if #{var.name} doesn't have a default" if var.default_value.nil? && !var.type.nilable? %}
@{{var.name}} = {{var.default_value}}
{% end %}
{% end %}
end
def after_initialize
@@instance = self
end
def self.get
@@instance ||= new
end
end
end
end
@@ -0,0 +1,39 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
module CliGen
class Command
macro define_command_initializer
def initialize(*, handler : CliGen::BaseCommandNode)
{% verbatim do %}
Log.debug { "#{self.class.name}#initialize : Initializing class" }
{% for var in @type.instance_vars %}
Log.debug { "{{@type.name}}#initialize : Checking {{var.name}}" }
{% anno = (var.annotation(CliGen::Argument) || var.annotation(CliGen::Selection)) %}
{% if anno %}
{% raise "ERROR : #{@type.name}#initialize : Argument '#{var.name}' cannot be a nilable type (#{var.type}) — flags always resolve to a concrete value" if var.type.union? %}
Log.debug { "{{@type.name}}#initialize : {{var.name}} is a CliGen managed ivar. Will attempt to gather from associated CliGen::Flag" }
if flg = handler.flags.find{|f| f.var == {{var.name.stringify}} && f.long == {{anno[:long]}}}
Log.debug { "{{@type.name}}#initialize : {{var.name}} : Found Flag(long: #{flg.long}). Calling validate! to make sure data provided (in whatever format) is valid" }
flg.validate!
Log.debug { "{{@type.name}}#initialize : {{var.name}} : Found Flag(long: #{flg.long}). Data was valid seems like (or at least a default was set)" }
@{{var.id}} = flg.as(CliGen::Flag({{var.type}})).value!
else
raise CliGen::FlagNotFoundError.new("{{@type.name}}\#{{@def.name}} : No flag found for \"{{var.name}}\"")
end
{% else %}
Log.debug { "{{@type.name}}#initialize : {{var.name}} is not a CliGen managed ivar. Will initialize to default defined in class" }
{% raise "ERROR : #{@type.name}#{@def.name} : Instance Variable(#{var.name}) is not handled by CliGen and does not have a default value" if var.default_value.nil? %}
@{{var.id}} = {{var.default_value}}
{% end %}
{% end %}
{% if @type.has_method? :after_initialize %}
Log.debug { "{{@type.name}}#initialize : Developer defined 'after_initialize' so going to call it" }
after_initialize
{% end %}
{% end %}
end
end
end
end
+13
View File
@@ -0,0 +1,13 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
module CliGen
class Command
macro help_template(filepath)
{% raise "ERROR : CliGen::Command.help_template : #{filepath} does not exist" unless file_exists? filepath %}
HELP_TEMPLATE = {{`readlink -f #{filepath}`.strip.stringify}}
{% puts "DEBUG : #{@type.name} : Set HELP_TEMPLATE to #{filepath}" if env("DEBUG") %}
{% debug if env("DEBUG") %}
end
end
end
-70
View File
@@ -1,70 +0,0 @@
module CliGen::Parser
macro extended
{% verbatim do %}
macro define_parser
def self.make_parser(parent_parser : OptionParser) : Nil
{% puts "#{@type.name} OptionParser is being generated" %}
{% name = @type.name.split("::").last %}
{% var = name.downcase %}
{% methods = @type.class.methods %}
{% info = @type.annotation(::CliGen::CommandInfo) %}
{% raise "ERROR : No CommandInfo annotation provided to {{@type.name}}" unless info %}
subparser = OptionParser.new do |parser|
parser.banner = {{@type.name}}::HEADER
{% selections = methods.select(&.annotation(::CliGen::CommandSelection)) %}
{% if selections.size > 0 %}
CliGen.define_section("Selections", parser)
{% for selection in selections %}
{% selection_anno = selection.annotation(::CliGen::CommandSelection) %}
parser.on({{selection.name.stringify}}, {{selection_anno[:description]}}){
{{@type.name}}.{{selection_anno[:selector]}}= {{selection.name.stringify}}
}
{% end %}
{% end %}
{% subcommands = methods.select(&.annotation(::CliGen::SubCommand)) %}
{% if subcommands.size > 0 %}
CliGen.define_section("Subcommands", parser)
{% for subcommand in subcommands %}
{% subcommand_anno = subcommand.annotation(::CliGen::SubCommand) %}
parser.on({{subcommand.name.stringify}}, {{subcommand_anno[:description]}}){
{{@type.name}}.action= {{subcommand.name.stringify}}
}
{% end %}
{% end %}
{% arguments = methods.select(&.annotation(::CliGen::CommandArgument)) %}
{% if arguments.size > 0 %}
CliGen.define_section("Provide Arguments", parser)
{% for argument in arguments %}
{% argument_anno = argument.annotation(::CliGen::CommandArgument) %}
{% if argument_anno[:short] == "" && argument_anno[:long] != "" %}
parser.on({{argument_anno[:long]}}, {{argument_anno[:description]}}){|val|
{% elsif argument_anno[:short] != "" && argument_anno[:long] == "" %}
parser.on({{argument_anno[:short]}}, {{argument_anno[:description]}}){|val|
{% else %}
parser.on({{argument_anno[:short]}}, {{argument_anno[:long]}}, {{argument_anno[:description]}}){|val|
{% end %}
{{@type.name}}.{{argument.name}}(val)
}
{% end %}
{% end %}
CliGen.define_default_flags(parser)
end
parent_parser.on({{var}}, {{info[:description]}}){
raise "ERROR : {{var.id}} not found in ARGV" unless i = ARGV.index({{var}})
## Removing all preceeding arguments so that only the actual required
## args for the next command are present
ARGV.shift(i+1)
abort subparser if ARGV.empty?
subparser.parse
{{@type.name}}.run
}
end
end
{% end %}
end
end
+24
View File
@@ -0,0 +1,24 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
module CliGen
class Command
macro selection(variable, description, options, short = nil, long = nil, validation = nil, on_match = nil)
{% raise "ERROR : CliGen::Command.selection : First selection must be a TypeDeclaration (ex: '<var> : <type> [= val]')" unless variable.is_a? TypeDeclaration %}
{% if short %}
{% raise "ERROR : CliGen::Command.selection : Provided short must be a string" unless short.is_a? StringLiteral %}
{% end %}
{% long = "--#{variable.var}" if long.nil? %}
{% raise "ERROR : CliGen::Command.selection : Provided long must be a flag format" unless long =~ /^--[a-zA-Z0-9-_]+/ %}
{% raise "ERROR : CliGen::Command.selection : Provided long must be a string" unless long.is_a? StringLiteral %}
{% raise "ERROR : CliGen::Command.selection : You must provide a short or long" unless long || short %}
{% raise "ERROR : CliGen::Command.selection : You must provide a description" unless description %}
{% raise "ERROR : CliGen::Command.selection : Provided description must be a String" unless description.is_a? StringLiteral %}
{% options = options.resolve if options.is_a? Path %}
{% raise "ERROR : CliGen::Command.selection : Provided options must be an ArrayLiteral" unless options.is_a? ArrayLiteral %}
@[CliGen::Argument(short: {{short}}, long: {{long}}, description: {{description}}, validation: {{validation}}, on_match: {{on_match}}, options: {{options}}, delimiter: "-")]
@{{variable}}
end
end
end
+22
View File
@@ -0,0 +1,22 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
module CliGen
class Command
macro subcommand(func, description, examples = nil, &block)
{% raise "ERROR : CliGen::Command.subcommand : First argument must be a TypeDeclaration, or Call (ex: '<var> : <type>' or <var>)" unless func.is_a? TypeDeclaration || func.is_a? Call %}
{% raise "ERROR : CliGen::Command.subcommand : You must provide a description" unless description %}
{% raise "ERROR : CliGen::Command.subcommand : Provided description must be a String" unless description.is_a? StringLiteral %}
{% unless examples.nil? %}
{% examples = examples.resolve if examples.is_a? Path %}
{% raise "ERROR : CliGen::Command.subcommand : Provided example must be an Array" unless examples.is_a? ArrayLiteral %}
{% end %}
{% raise "ERROR : CliGen::Command.subcommand : You MUST provide a function body" unless block %}
@[CliGen::SubCommand(description: {{description}}, examples: {{examples}})]
def {{func}}
{{block.body}}
end
end
end
end
+236
View File
@@ -0,0 +1,236 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
require "log"
require "ecr"
require "./command_node/base"
require "./global_flag"
require "./match_type"
require "./flag"
require "./arg"
module CliGen
class CommandNode(T) < BaseCommandNode
def initialize(
name : String,
flags : Array(BaseFlag),
commands : Array(BaseCommandNode),
pre_run_commands : Array(RunCommand),
post_run_commands : Array(RunCommand),
description : String? = nil
)
meta = CommandMeta.new(
cls: {{T.name.stringify}}
)
super(name, flags, commands, pre_run_commands, post_run_commands, meta, description)
end
def subcommands : Array(SubCommandInfo)
{% begin %}
{% subcmds = T.methods.select(&.annotation(CliGen::SubCommand)) %}
{% if subcmds.empty? %}
[] of SubCommandInfo
{% else %}
[
{% for cmd in subcmds %}
{% anno = cmd.annotation(CliGen::SubCommand) %}
SubCommandInfo.new(
name: {{cmd.name.stringify}},
description: {{anno[:description]}},
examples: {% if anno[:examples] %} {{anno[:examples]}} {% else %} nil {% end %}
),
{% end %}
]
{% end %}
{% end %}
end
def verbose? : Bool
@verbose_flag ||= get(long: "--verbose").not_nil!.as(Flag(Bool))
@verbose_flag.not_nil!.value!
end
def help : String
{% begin %}
{% if T.has_constant? "HELP_TEMPLATE" %}
{% puts "#{T} was found to have HELP_TEMPLATE defined using this instead" if env("DEBUG") %}
ECR.render({{T.constant("HELP_TEMPLATE")}})
{% elsif CliGen.has_constant? "HELP_OVERRIDE_TEMPLATE" %} # If we have a global override use it
{% puts "Global override found. Using" if env("DEBUG") %}
ECR.render({{CliGen::HELP_OVERRIDE_TEMPLATE}})
{% else %}
{% puts "No type overrided help output. Using default" if env("DEBUG") %}
ECR.render("lib/cligen/src/cligen/template/cmd_help.ecr")
{% end %} # otherwise
{% debug if env("DEBUG") %}
{% end %}
end
def check! : Nil
@flags.each(&.check!)
check_for_duplicate_flags!(@flags + CliGen::GLOBAL_FLAGS)
@commands.each(&.check!)
check_for_duplicate_subcommands!
{% unless T == Nil %}
raise CliGen::MissingDispatchError.new("CommandNode(#{@name})#check! : {{T}} has no subcommands and no #main defined") \
if subcommands.empty? && !{{T.has_method?(:main)}}
{% end %}
end
def process(args : Array(CliGen::Arg)) : Nil
Log.trace { "CommandNode(#{@name})#process(#{args.map(&.value)}) : Entered" }
check!
passed_execution = false
matched_subcommand : String? = nil
@pre_run_commands.each(&.call)
args.each do |arg|
Log.trace { "CommandNode(#{@name})#process : Iterating with arg Arg(index: #{arg.index}, value: #{arg.value})" }
if arg.processed?
Log.debug { "CommandNode(#{@name})#process : Arg(#{arg.value}) was already processed. Skipping" }
next
end
Log.trace { "CommandNode(#{@name})#process : Arg(#{arg.value}) wasn't processed yet. Continuing and marking arg as processed" }
arg.processed
case match = find_match(arg.value)
when BaseCommandNode
Log.trace {
"CommandNode(#{@name})#process : Arg(#{arg.value}) was found to be a child command. " \
"Handing off rest of execution & parsing to it"
}
# Hand off remainder to the child; we're done at this level
{% begin %}
case match
{% for cls in CliGen::Command.subclasses %}
when CliGen::CommandNode({{cls.name}})
match.as(CommandNode({{cls}})).process(args.reject(&.processed?))
exit 0
{% end %}
else
raise CliGen::UnknownCommandNodeError.new("CommandNode(#{@name})#process : matched a BaseCommandNode that isn't a known CommandNode(T)")
end
{% end %}
passed_execution = true
when BaseFlag
Log.trace { "CommandNode(#{@name})#process : Arg(#{arg.value}) was found to be a flag" }
# Ensuring we catch any exceptions to have them abort with the
# error message if caught
handle_flag_raises do
if match.requires_arg?
Log.trace { "CommandNode(#{@name})#process : Arg(#{arg.value}) flag requires values so handing it the data without a match or that matches it's valid options" }
match.process(args.reject(&.processed?).take_while{|v|
find_match(v.value) == CliGen::MatchType::NoMatch || !!match.meta.options.try(&.includes?(v.value))
})
else
Log.trace { "CommandNode(#{@name})#process : Arg(#{arg.value}) flag does not require an argument so just calling process" }
match.process
end
end
when MatchType::SubCommand
Log.trace { "CommandNode(#{@name})#process : Arg(#{arg.value}) was found to be a subcomand. Marking it as the matched sub-command" }
raise CliGen::InternalError.new("CommandNode(#{@name})#process : subcommand '#{matched_subcommand}' was already matched — duplicate subcommand token") if matched_subcommand
matched_subcommand = arg.value
when MatchType::Help
Log.trace { "CommandNode(#{@name})#process : Arg(#{arg.value}) is a help option. Raising to have App print out help output" }
raise CliGen::HelpRequestedError.new(help)
when MatchType::FlagWithArg
Log.debug { "CommandNode(#{@name})#process : Arg(#{arg.value}) was found to be a flag with an arg <flag>=<arg>" }
if regex_match = CliGen::Regex::FLAG_WITH_ARG.match(arg.value)
Log.trace { "CommandNode(#{@name})#process : Arg(#{arg.value}) flag: #{regex_match["flag"]} & arg: #{regex_match["arg"]}" }
case flag_match = find_match(regex_match["flag"])
when BaseFlag
Log.debug { "CommandNode(#{@name})#process : Arg(#{arg.value}) flag: #{regex_match["flag"]} is actually a flag" }
handle_flag_raises do
flag_match.process([CliGen::Arg.new(value: regex_match["arg"], index: arg.index)])
end
else
Log.debug { "CommandNode(#{@name})#process : Arg(#{arg.value}) flag: #{regex_match["flag"]} had no flag matches" }
raise CliGen::UnknownCommandNodeError.new("CommandNode(#{@name}).process : No flag matched '#{regex_match["flag"]}'")
end
else
raise CliGen::RegexInvariantError.new("CommandNode(#{@name})#process : FLAG_WITH_ARG matched in find_match but failed on re-match — this is a framework bug")
end
when MatchType::FlagMultipleShort
Log.debug { "CommandNode(#{@name})#process : Arg(#{arg.value}) was found to be an combined short flag" }
val = arg.value.gsub(/^-/,"")
# If the next character in the series is a flag assume the remaining are flags as well.
if flag?("-#{val[1]}")
chars = val.chars
chars.map { |c| "-#{c}" }.each_with_index do |flag, index|
Log.trace { "CommandNode(#{@name})#process : Arg(#{arg.value}) : char(flag: #{flag}, index: #{index}) being processed" }
case match = find_match(flag)
when BaseFlag
Log.trace { "CommandNode(#{@name})#process : Arg(#{arg.value}) : char(flag: #{flag}, index: #{index}) was actually found to be a flag" }
# If this is the last flag in the series let it process others
handle_flag_raises do
## If this is the last flag provided in the clump do the thing
if index == chars.size - 1
if match.requires_arg?
match.process(args.reject(&.processed?).take_while{|v|
find_match(v.value) == CliGen::MatchType::NoMatch || !! match.meta.options.try(&.includes?(v.value))
})
else
match.process
end
else
raise CliGen::FlagBundleError.new("#{CliGen::APPNAME}: cannot bundle '#{flag}' — it requires an argument") if match.requires_arg?
match.process
end
end
when MatchType::NoMatch
raise CliGen::UnknownFlagError.new("#{CliGen::APPNAME}: unknown flag '#{flag}'")
end
end
else
# In this case we assume the characters following the flag is the argument
raise CliGen::FlagArgumentError.new("#{CliGen::APPNAME}: inline flag arguments are not supported — did you mean '-#{val[0]} #{val[1..]}'?")
end
when MatchType::NoMatch
raise CliGen::HelpRequestedError.new("#{CliGen::APPNAME}: unknown token '#{arg.value}'\n\n#{help}")
end
end
@post_run_commands.each(&.call)
{% unless T == Nil %}
unless passed_execution
cls = T.new(handler: self.as(CliGen::BaseCommandNode))
{% for cmd in T.methods.select(&.annotation(CliGen::PreRunCommand)) %}
cls.{{cmd.name}}
{% end %}
{% subcmds = T.methods.select(&.annotation(CliGen::SubCommand)) %}
{% begin %}
case matched_subcommand
{% for cmd in subcmds %}
when {{cmd.name.stringify}}
cls.{{cmd.name}}
{% end %}
else
{% if T.has_method?(:main) %}
cls.main
{% else %}
puts "ERROR : CommandNode(#{@name})#process : No subcommand matched and no #main defined"
puts help
{% end %}
exit 0
end
{% end %}
end
{% else %}
puts help
exit 0
{% end %}
end
end
end
+177
View File
@@ -0,0 +1,177 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
require "../flag"
require "./command_meta"
require "./subcommand_meta"
module CliGen
alias RunCommand = Proc(Nil)
# Non-generic base that lets the tree hold heterogeneous CommandNode(T) children.
# Everything that doesn't depend on T lives here.
abstract class BaseCommandNode
getter name : String
getter flags : Array(BaseFlag)
getter commands : Array(BaseCommandNode)
getter description : String?
getter meta : CommandMeta
@pre_run_commands : Array(RunCommand)
@post_run_commands : Array(RunCommand)
Log = ::Log.for(CliGen::CommandNode)
def initialize(
@name : String,
@flags : Array(BaseFlag),
@commands : Array(BaseCommandNode),
@pre_run_commands : Array(RunCommand),
@post_run_commands : Array(RunCommand),
@meta : CommandMeta,
@description : String? = nil
)
end
def all_flags : Array(BaseFlag)
@flags + @commands.flat_map(&.all_flags)
end
def check_for_duplicate_subcommands!
failures = [] of Tuple(String, Array(BaseCommandNode))
@commands.group_by(&.name).each do |command, cmd_group|
if cmd_group.size > 1
failures << Tuple.new(command, cmd_group)
end
end
unless failures.empty?
error_buffer = "ERROR : #{self.class}(%s)#check! : Found Command Name Duplicates \n%s"
format = "\n%s:\n%s\n\n"
buffer = ""
failures.each do |name, cmds|
buffer += format % [name, cmds.map{|c| "- #{c.meta.cls} (#{c.description})"}.join("\n") ]
end
raise CliGen::DuplicateCommandError.new(error_buffer % [@name, buffer])
end
end
def check_for_duplicate_flags!(flags : Array(BaseFlag)) : Nil
Log.trace { "CommandNode(#{@name})#check_for_duplicate_flags! : entered with #{flags.map(&.long_key)}" }
shorts = flags.compact_map(&.short)
short_duplicates = [] of String
longs = flags.compact_map { |f| f.long_key unless f.long_key.empty? }
long_duplicates = [] of String
last_short : String = ""
shorts.sort.each do |short|
short_duplicates << short if last_short == short
last_short = short
end
last_long : String = ""
longs.sort.each do |long|
long_duplicates << long if last_long == long
last_long = long
end
unless long_duplicates.empty? && short_duplicates.empty?
error_buffer = "ERROR : CommandNode(%s)#check! : Found Duplicates : %s"
message = ""
unless long_duplicates.empty?
message += "\nLong:\n%s\n" % long_duplicates.map { |f| "- #{f}" }.join("\n")
end
unless short_duplicates.empty?
message += "\nShort:\n%s" % short_duplicates.map { |f| "- #{f}" }.join("\n")
end
raise CliGen::DuplicateFlagError.new(error_buffer % [@name, message])
end
end
def get(*, long : String) : BaseFlag?
Log.trace { "CommandNode(#{@name})#get(long: #{long}) : entered" }
@flags.find{|f| f.long_key == long} || @commands.find(&.flag?(long)).try(&.get(long: long)) || CliGen::GLOBAL_FLAGS.find(&.long_key.==(long))
end
def get(*, short : String) : BaseFlag?
Log.trace { "CommandNode(#{@name})#get(short: #{short}) : entered" }
@flags.find{|f| f.short == short} || @commands.find(&.flag?(short)).try(&.get(short: short)) || CliGen::GLOBAL_FLAGS.find(&.short.==(short))
end
def handle_flag_raises(&) : Nil
begin
yield
rescue e : CliGen::RuntimeError
abort e.message
end
end
def find_match(arg : String)
Log.trace { "CommandNode(#{@name})#find_match(#{arg}) : Entered" }
if subcommand?(arg)
Log.debug { "CommandNode(#{@name})#find_match(#{arg}) : arg found to be subcommand" }
return CliGen::MatchType::SubCommand
end
case arg
when "-h", "--help"
Log.debug { "CommandNode(#{@name})#find_match(#{arg}) : was found to be a help flag" }
CliGen::MatchType::Help
when CliGen::Regex::FLAG_REGEX
Log.debug { "CommandNode(#{@name})#find_match(#{arg}) : arg found to match the format of a flag" }
if flg = flag?(arg)
Log.debug { "CommandNode(#{@name})#find_match(#{arg}) : arg found to be a Flag(long: #{flg.long_key})" }
flg
else
Log.debug { "CommandNode(#{@name})#find_match(#{arg}) : arg found not to have a flag associated with it" }
CliGen::MatchType::NoMatch
end
when CliGen::Regex::FLAG_WITH_ARG
Log.debug { "CommandNode(#{@name})#find_match(#{arg}) : arg found to match the format of a flag with an arg <flag>=<arg>" }
CliGen::MatchType::FlagWithArg
when CliGen::Regex::FLAG_MULTIPLE_SHORT
Log.debug { "CommandNode(#{@name})#find_match(#{arg}) : arg found to match the clumped flag format" }
CliGen::MatchType::FlagMultipleShort
else
Log.debug { "CommandNode(#{@name})#find_match(#{arg}) : Found no obvious match format wise. Checking if arg is a command" }
if cmd = @commands.find(&.name.== arg)
Log.debug { "CommandNode(#{@name})#find_match(#{arg}) : Looks like the arg matched a defined command" }
cmd
else
Log.debug { "CommandNode(#{@name})#find_match(#{arg}) : No match found for arg" }
CliGen::MatchType::NoMatch
end
end
end
def subcommands? : Bool
subcommands.size > 0
end
def subcommand?(arg : String) : Bool
Log.trace { "CommandNode(#{@name})#subcommand?(#{arg}) : Entered" }
subcommands.any?(&.name.== arg)
end
def flag?(arg : String) : BaseFlag?
Log.trace { "CommandNode(#{@name})#flag?(#{arg}) : Entered" }
get(short: arg) || get(long: arg)
end
# Converts String array to Arg array and hands off to the typed process method
def process(args : Array(String)) : Nil
Log.trace { "CommandNode(#{@name})#process(#{args}) : Entered" }
new_args = args.each_with_index.map { |arg, i| CliGen::Arg.new(value: arg, index: i) }.to_a
process(new_args)
end
abstract def subcommands : Array(SubCommandInfo)
abstract def check! : Nil
abstract def process(args : Array(CliGen::Arg)) : Nil
end
end
+7
View File
@@ -0,0 +1,7 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
module CliGen
record CommandMeta,
cls : String
end
@@ -0,0 +1,10 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
module CliGen
record SubCommandInfo,
name : String,
description : String,
examples : Array(String)?
end
+89
View File
@@ -0,0 +1,89 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
module CliGen
# Base for all CliGen exceptions
class Error < Exception; end
# -------------------------------------------------------------------------
# Internal errors - framework invariant violations, should never reach users
# -------------------------------------------------------------------------
class InternalError < Error; end
# Arg#processed was called a second time on the same Arg
class ArgReprocessedError < InternalError; end
# A token matched FLAG_WITH_ARG in find_match but the regex failed on re-match
class RegexInvariantError < InternalError; end
# A BaseCommandNode was matched but couldn't be cast to any known CommandNode(T)
class UnknownCommandNodeError < InternalError; end
# -------------------------------------------------------------------------
# Configuration errors - shard consumer wired something up incorrectly
# -------------------------------------------------------------------------
class ConfigurationError < Error; end
# -h or --help was used as a flag short/long (reserved for internal help)
class ReservedFlagError < ConfigurationError; end
# Duplicate short or long flags detected during check!
class DuplicateFlagError < ConfigurationError; end
# Duplicate command names detected during check!
class DuplicateCommandError < ConfigurationError; end
# A CommandNode(T) has no subcommands and no #main defined
class MissingDispatchError < ConfigurationError; end
# No flag was found in the handler for a Command ivar during initialize
class FlagNotFoundError < ConfigurationError; end
# A flag that requires an argument was processed with an empty argv
class FlagMissingArgumentError < ConfigurationError; end
# A Parsable type's parse_args did not mark any args as processed
class ParseableInvariantError < ConfigurationError; end
# -------------------------------------------------------------------------
# Runtime errors - bad user input at the CLI level
# -------------------------------------------------------------------------
class RuntimeError < Error; end
# A required flag was not provided and has no env var or default to fall back on
class MissingRequiredFlagError < RuntimeError; end
# A setter's validation proc rejected the provided value
class ValidationError < RuntimeError; end
# A flag token was provided where a value argument was expected
class FlagArgumentError < RuntimeError; end
# A provided value doesn't satisfy type or format requirements (wrong type, bad format, invalid bool/date string)
class InvalidFlagValueError < RuntimeError; end
# A provided value is not in the flag's allowed options list
class InvalidOptionError < RuntimeError; end
# An unrecognised flag token was encountered during parsing
class UnknownFlagError < RuntimeError; end
# A flag that requires an argument was included in a short-flag bundle
class FlagBundleError < RuntimeError; end
# -------------------------------------------------------------------------
# Help signal - not an error; exit 0 after printing
# -------------------------------------------------------------------------
# Raised when -h/--help is matched; carries the rendered help string
class HelpRequestedError < Error; end
# -------------------------------------------------------------------------
# CliGen::Timeparse Errors
# -------------------------------------------------------------------------
class TimeParseError < RuntimeError; end
end
+349
View File
@@ -0,0 +1,349 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
require "./flag/base"
require "./timeparse"
require "./exceptions"
require "./arg"
module CliGen
class Flag(T) < BaseFlag
@value : T?
@default : T?
@options : Array(T)?
@validate : (T -> Bool)?
@on_match : Proc(T, Nil)?
@format : ::Regex?
def initialize(
var : String,
short : String?,
long : String,
env_var : String,
description : String,
delimiter : String = ",",
@default : T? = nil,
@options : Array(T)? = nil,
@validate : (T -> Bool)? = nil,
@on_match : Proc(T, Nil)? = nil,
@format : ::Regex? = nil
)
{% unless T.class.has_method? :to_s %}
{% raise "ERROR : Flag(#{T}) : Error your flag type must have a to_s method" %}
{% end %}
{% if T < Array %}
{% elem = T.type_vars.first %}
{% raise "ERROR : Flag(#{T}) : Error your flag subtype #{elem} must have a to_s method" unless elem.class.has_method? :to_s %}
{% end %}
unless @default.nil?
{% if T < Array %}
default = "[" + @default.not_nil!.map(&.to_s).join(", ") + "]"
{% else %}
default = @default.not_nil!.to_s
{% end %}
else
default = ""
end
meta = FlagMeta.new(
type: {{T.stringify}},
array: {{ T < Array ? true : false }},
options: {% if T < Array %} @options.try(&.first.map(&.to_s)) {% else %} @options.try(&.map(&.to_s)) {% end %},
default: default,
format: @format.try(&.source)
)
super(var, short, long, env_var, description, delimiter, meta)
end
def requires_arg? : Bool
{{T}} != Bool
end
def process(argv : Array(Arg) = [] of Arg) : Nil
Log.trace { "Flag(#{@long}, type: #{@meta.type})#process : entered with args #{argv.map(&.value)}" }
if requires_arg?
raise CliGen::FlagMissingArgumentError.new("Flag(#{T}, long: #{@long_key}) : requires an argument but provided array is empty") if argv.empty?
raise CliGen::FlagArgumentError.new("Flag(#{T}, long: #{@long_key}) : a flag token was provided where a value was expected (got: #{argv.first.value})") if argv.first.flag?
end
{% if T == Bool %}
@value = true
{% elsif T < Array %}
{% raise "ERROR : Flag(#{T}) : You cannot define multiple types of array entries" if T.type_vars.size > 1 %}
{% elem = T.type_vars.first %}
Log.debug { "Flag(long: #{@long}, type: #{@meta.type})#process : Beginning iteration of arguments" }
argv.each do |arg|
Log.trace { "Flag(long: #{@long}, type: #{@meta.type})#process : Iterating with Arg(index: #{arg.index}, value: #{arg.value})" }
if arg.flag?
Log.debug { "Flag(long: #{@long}, type: #{@meta.type})#process : Arg(index: #{arg.index}, value: #{arg.value}) was a flag. Breaking loop" }
break
end
unless @format.nil?
Log.debug { "Flag(long: #{@long}, type: #{@meta.type}) : Arg(index: #{arg.index}, value: #{arg.value}) format regex was provided. Going to check argument value against it" }
unless arg.value.includes?(@delimiter)
unless arg.value =~ @format
Log.debug { "Flag(long: #{@long}, type: #{@meta.type}) : Arg(index: #{arg.index}, value: #{arg.value}) was not found to be matching the defined filter #{@format}. So breaking from parse loop" }
break
end
end
end
{% if elem < Int %}
{% int_case = elem.stringify =~ /^UInt/ ? "uint?".id : "int?".id %}
if arg.value.includes?(@delimiter)
Log.debug { "Flag(long: #{@long}, type: #{@meta.type})#process : Arg(index: #{arg.index}, value: #{arg.value}) argument provided is delimited with provided delimiter . Splitting and parsing individual values" }
@value = (@value || T.new) + arg.value.split(@delimiter).map do |val|
Log.trace { "Flag(long: #{@long}, type: #{@meta.type})#process : Arg(index: #{arg.index}, value: #{arg.value}) : Indexing with Value(#{val})" }
val = val.strip
unless arg.{{int_case}}(val)
raise CliGen::InvalidFlagValueError.new("Flag({{T}}, long: #{@long_key}) : '#{val}' is not a valid {{elem}}")
end
{{elem}}.new(val)
end
else
unless arg.{{int_case}}
raise CliGen::InvalidFlagValueError.new("Flag({{T}}, long: #{@long_key}) : '#{arg.value}' is not a valid {{T}}")
end
(@value ||= T.new) << {{elem}}.new(arg.value)
end
{% elsif elem < Float %}
if arg.value.includes?(@delimiter)
@value = (@value || T.new) + arg.value.split(@delimiter).map do |val|
val = val.strip
unless CliGen::Arg.float?(val)
raise CliGen::InvalidFlagValueError.new("Flag({{T}}, long: #{@long_key}) : '#{val}' is not a valid {{T}}")
end
{{elem}}.new(val)
end
else
unless arg.float?
raise CliGen::InvalidFlagValueError.new("Flag({{T}}, long: #{@long_key}) : '#{arg.value}' is not a float")
end
(@value ||= T.new) << {{elem}}.new(arg.value)
end
{% elsif elem == String %}
if arg.value.includes?(@delimiter)
Log.debug { "Flag(long: #{@long}, type: #{@meta.type})#process : Arg(index: #{arg.index}, value: #{arg.value}) argument provided is delimited with provided delimiter . Splitting and parsing individual values" }
@value = (@value || [] of String) + arg.value.split(@delimiter).map { |v|
Log.trace { "Flag(long: #{@long}, type: #{@meta.type})#process : Arg(index: #{arg.index}, value: #{arg.value}) : Indexing with Value(#{v})" }
unless @format.nil?
Log.debug { "Flag(long: #{@long}, type: #{@meta.type})#process : Arg(index: #{arg.index}, value: #{arg.value}) format regex (#{@format.not_nil!.source}) was provided. Checking value against it" }
raise CliGen::InvalidFlagValueError.new("Flag({{T}}, long: #{@long_key}) : '#{v}' does not match required format /#{@format.not_nil!.source}/") unless v =~ @format
end
v
}
else
if ! @format.nil? && arg.value !~ @format
raise CliGen::InvalidFlagValueError.new("Flag({{T}}, long: #{@long_key}) : '#{arg.value}' does not match required format /#{@format.not_nil!.source}/")
end
(@value ||= [] of String) << arg.value
end
{% elsif elem.class < CliGen::Coercable %}
if arg.value.includes?(@delimiter)
@value = (@value || [] of {{elem}}) + arg.value.split(@delimiter).map { |i| {{elem}}.coerce(i) }
else
@value = (@value || [] of {{elem}}) + [({{elem}}.coerce(arg.value))]
end
{% else %}
{% raise "ERROR : Flag(#{T}) : #{elem} is not a coercable type. If you wish to coerce it from a bare string extend with CliGen::Coercable & implement the class method" %}
{% end %}
arg.processed
end
{% elsif T < Int %}
{% int_case = T.stringify =~ /^UInt/ ? "uint?".id : "int?".id %}
unless argv.first.{{int_case}}
raise CliGen::InvalidFlagValueError.new("Flag(#{T}, long: #{@long_key}) : '#{argv.first.value}' is not a valid {{T}}")
end
@value = T.new(argv.first.value)
argv.first.processed
{% elsif T < Float %}
unless argv.first.float?
raise CliGen::InvalidFlagValueError.new("Flag(#{T}, long: #{@long_key}) : '#{argv.first.value}' is not a valid {{T}}")
end
@value = T.new(argv.first.value)
argv.first.processed
{% elsif T == Time %}
begin
@value = ::CliGen::Timeparse.parse(argv.first.value)
argv.first.processed
rescue e : ::CliGen::TimeParseError
raise CliGen::InvalidFlagValueError.new("Flag(#{T}, long: #{@long_key}) : #{e.message}")
end
{% elsif T == String %} # String
if ! @format.nil? && argv.first.value !~ @format
raise CliGen::InvalidFlagValueError.new("Flag(#{T}, long: #{@long_key}) : '#{argv.first.value}' does not match required format /#{@format.not_nil!.source}/")
end
@value = argv.first.value
argv.first.processed
{% elsif T.class < CliGen::Parsable %}
unprocessed = argv.reject(&.processed?)
Log.trace { "Flag(long: #{@long}, type: #{@meta.type})#process : unprocessed before : #{unprocessed.map(&.value)}" }
@value = T.parse_args(argv)
Log.trace { "Flag(long: #{@long}, type: #{@meta.type})#process : unprocessed after : #{unprocessed.reject(&.processed?).map(&.value)}" }
# Essentially if the unprocessed array stays the same (aka if it shows the same number of unprocessed
# arguments it will complain and raise. Only possible because the array holds references to the objects
# in case the user (for some reason) shifts/pops options out when getting/parsing data from argv)
if unprocessed.size == unprocessed.reject(&.processed?).size
raise CliGen::ParseableInvariantError.new("Flag({{T}}, long: #{@long_key})#process : {{T}}#parse_args did not mark any args as processed")
end
{% else %}
{% raise "ERROR : Flag({{T}}#process : Generic Type #{T} is not supported. To add support you must extend with CliGen::Parsable & implement the class method" %}
{% end %}
validate!
@on_match.try(&.call(value!))
end
def value! : T
Log.trace { "Flag(long: #{@long}, type: #{@meta.type})#value! : called" }
# Essentially if the unprocessed array stays the same (aka if it shows the same number of unprocessed
v = @value
# Priority: provided arg → env var → default → abort
if v.nil?
if raw = ENV[@env_var]?
v = coerce(raw)
end
end
v ||= @default
raise CliGen::MissingRequiredFlagError.new("#{CliGen::APPNAME}: required flag #{@long_key} was not provided") if v.nil?
validate!(v)
v.not_nil!
end
def raw_value : String?
Log.trace { "Flag(long: #{@long}, type: #{@meta.type})#raw_value : called" }
{% if T == Bool %}
@value.try(&.to_s)
{% elsif T <= Array %}
@value.try(&.join(","))
{% else %}
@value.try(&.to_s)
{% end %}
end
def satisfied? : Bool
Log.trace { "Flag(long: #{@long}, type: #{@meta.type})#satisfied? : called" }
return true if !@value.nil?
return true if @env_var && ENV[@env_var]?
return true if !@default.nil?
false
end
def validate!(v : T? = nil) : Nil
Log.trace { "Flag(long: #{@long}, type: #{@meta.type})#validate! : called" }
v = value! if v.nil?
if opts = @options
{% if T < Array %}
v.each do |v2|
raise CliGen::InvalidOptionError.new("#{CliGen::APPNAME}: '#{v2}' is not a valid value for #{@long_key} (valid: #{opts.first.join(", ")})") unless opts.first.includes?(v2)
end
{% else %}
raise CliGen::InvalidOptionError.new("#{CliGen::APPNAME}: '#{v}' is not a valid value for #{@long_key} (valid: #{opts.join(", ")})") unless opts.includes?(v)
{% end %}
end
if check = @validate
raise CliGen::ValidationError.new("#{CliGen::APPNAME}: validation failed for #{@long_key} (got: #{v})") unless check.call(v)
end
end
def check! : Nil
Log.trace { "Flag(long: #{@long}, type: #{@meta.type})#check! : called" }
raise CliGen::ReservedFlagError.new("Flag({{T}}, long: #{@long})#check! : -h is reserved for internal help") if @short == "-h"
raise CliGen::ReservedFlagError.new("Flag({{T}}, long: #{@long})#check! : --help is reserved for internal help") if @long_key == "--help"
end
private def coerce(raw : String) : T
Log.trace { "Flag(long: #{@long}, type: #{@meta.type})#coerce : entered with \"#{raw}\"" }
{% if T == Bool %}
case raw
when /^(t|true|y|yes|1)$/i
true
when /^(f|false|n|no|0)$/i
false
else
raise CliGen::InvalidFlagValueError.new("Flag({{T}}, long: #{@long_key}) : '#{raw}' is not a valid boolean (expected: t/f/true/false/y/n/yes/no/1/0)")
end
{% elsif T < Int %}
{% int_case = T.stringify =~ /^UInt/ ? "uint?".id : "int?".id %}
unless CliGen::Arg.{{int_case}}(raw)
raise CliGen::InvalidFlagValueError.new("Flag({{T}}, long: #{@long_key}) : '#{raw}' is not a valid {{T}}")
end
T.new(raw)
{% elsif T < Float %}
unless CliGen::Arg.float?(raw)
raise CliGen::InvalidFlagValueError.new("Flag({{T}}, long: #{@long_key}) : '#{raw}' is not a valid {{T}}")
end
T.new(raw)
{% elsif T == Time %}
begin
::CliGen::Timeparse.parse(raw)
rescue e : ::CliGen::TimeParseError
raise CliGen::InvalidFlagValueError.new("Flag(#{T}, long: #{@long_key}) : #{e.message}")
end
{% elsif T < Array %}
if raw.includes?(@delimiter)
{% elem = T.type_vars.first %}
raw.split(@delimiter).map do |val|
unless @format.nil?
raise CliGen::InvalidFlagValueError.new("Flag({{T}}, long: #{@long_key}) : '#{val}' does not match required format /#{@format.not_nil!.source}/") unless val =~ @format
end
{% if elem < Int %}
val = val.strip
{% int_case = elem.stringify =~ /^UInt/ ? "uint?".id : "int?".id %}
unless CliGen::Arg.{{int_case}}(val)
raise CliGen::InvalidFlagValueError.new("Flag({{T}}, long: #{@long_key}) : '#{val}' is not a valid {{elem}}")
end
{{elem}}.new(val)
{% elsif elem < Float %}
unless CliGen::Arg.float?(val)
raise CliGen::InvalidFlagValueError.new("Flag({{T}}, long: #{@long_key}) : '#{val}' is not a valid {{elem}}")
end
{{elem}}.new(val)
{% elsif elem == String %}
val
{% elsif elem.class < CliGen::Coercable %}
{{elem}}.coerce(val)
{% else %}
{% raise "ERROR : Flag(#{T}) : #{elem} is not a coercable type. If you wish to coerce it from a bare string extend CliGen::Coercable & implement the class method" %}
{% end %}
end
else
if ! @format.nil? && raw !~ @format
raise CliGen::InvalidFlagValueError.new("Flag({{T}}, long: #{@long_key}) : '#{raw}' does not match required format /#{@format.not_nil!.source}/")
end
{% if elem < Int %}
{% int_case = elem.stringify =~ /^UInt/ ? "uint?".id : "int?".id %}
unless CliGen::Arg.{{int_case}}(raw)
raise CliGen::InvalidFlagValueError.new("Flag({{T}}, long: #{@long_key}) : '#{raw}' is not a valid {{elem}}")
end
[ {{elem}}.new(raw) ]
{% elsif elem < Float %}
unless CliGen::Arg.float?(raw)
raise CliGen::InvalidFlagValueError.new("Flag({{T}}, long: #{@long_key}) : '#{raw}' is not a valid {{elem}}")
end
[ {{elem}}.new(raw) ]
{% elsif elem == String %}
[ raw ]
{% elsif elem.class < CliGen::Coercable %}
[ {{elem}}.coerce(raw) ]
{% else %}
{% raise "ERROR : Flag(#{T}) : #{T} is not a coercable type. If you wish to coerce it from a bare string extend CliGen::Coercable & implement the class method" %}
{% end %}
end
{% elsif T == String %} # String
raw
{% elsif T.class < CliGen::Coercable %}
T.coerce(raw)
{% else %}
{% raise "ERROR : Flag(#{T}) : #{T} is not a coercable type. If you wish to coerce it from a bare string extend CliGen::Coercable & implement the class method" %}
{% end %}
end
end
end
+57
View File
@@ -0,0 +1,57 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
require "log"
require "./meta"
module CliGen
abstract class BaseFlag
getter var : String
getter short : String?
getter long : String
getter long_key : String
getter env_var : String
getter description : String
getter delimiter : String
getter meta : FlagMeta
Log = ::Log.for(CliGen::Flag)
def initialize(
@var : String,
@short : String?,
@long : String,
@env_var : String,
@description : String,
@delimiter : String,
@meta : FlagMeta
)
Log.trace {
"Flag was initialized:\n" \
"\t@var : #{@var}\n" \
"\t@short : #{@short}\n" \
"\t@long : #{@long}\n" \
"\t@env_var : #{@env_var}\n" \
"\t@description : #{@description}\n" \
"\t@delimiter : #{@delimiter}\n"
}
# if the user provides just a "--long" I want the @long_key to match it
if @long =~ /\s|=/
@long_key = @long.split(/\s|=/).first
else
@long_key = @long
end
end
def matches?(token : String) : Bool
Log.trace { "Flag(#{@long})#matches?(#{token}) : entered" }
token == @short || (!@long_key.empty? && token == @long_key)
end
abstract def satisfied? : Bool
abstract def validate! : Nil
abstract def raw_value : String?
abstract def check! : Nil
end
end
+12
View File
@@ -0,0 +1,12 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
module CliGen
# To be able to store metadata for use in the help output
record FlagMeta,
type : String,
array : Bool,
format : String?,
default : String,
options : Array(String)?
end
+9 -2
View File
@@ -1,4 +1,11 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
# This module just holds time formats to be used with ::Time.parse!/.parse/.parse_local
module CliGen::Format
INPUT_DATE_FORMAT = "%Y-%m-%d"
INPUT_DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
INPUT_DATE_PARTIAL = "%Y-%m-%d %H:%M:%S"
INPUT_DATE_FULL = "%Y-%m-%d %H:%M:%S %z"
INPUT_DATE_SIMPLE_WITH_TIMEZONE = "%Y-%m-%d %z"
INPUT_DATE_SIMPLE = "%Y-%m-%d"
INPUT_EPOCH = "@%s"
end
+17
View File
@@ -0,0 +1,17 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
require "./flag"
require "./global_flag/add_global_flag"
module CliGen
GLOBAL_FLAGS = [] of BaseFlag
add_global_flag(Bool,
short: "-v",
long: "--verbose",
env_var: "VERBOSE",
default: false,
description: "Enable verbose output from program & help output"
)
end
+44
View File
@@ -0,0 +1,44 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
module CliGen
macro add_global_flag(type, *, long, description, env_var = nil, short = nil, validation = nil, default = nil, on_match = nil)
{% raise "ERROR : CliGen.add_global_flag(#{long}) : type must be a TypeNode" unless type.resolve.is_a? TypeNode %}
{% raise "ERROR : CliGen.add_global_flag(#{long}) : long must begin a StringLiteral" unless long.is_a? StringLiteral %}
{% raise "ERROR : CliGen.add_global_flag(#{long}) : long must begin with --" unless long =~ /^--/ %}
{% if short %}
{% raise "ERROR : CliGen.add_global_flag(#{long}) : Short must be a StringLiteral" unless short.is_a? StringLiteral %}
{% raise "ERROR : CliGen.add_global_flag(#{long}) : Short must be a - with single char (ex: -a)" unless short =~ /^-[a-zA-Z]/ %}
{% end %}
{% unless validation.nil? %}
{% raise "ERROR : CliGen.add_global_flag(#{long}) : validation must be a Proc" unless validation.is_a? ProcLiteral %}
{% raise "ERROR : CliGen.add_global_flag(#{long}) : validation proc return type must be Bool \"->(...) : Bool {...}\"" unless validation.return_type.resolve == Bool %}
{% raise "ERROR : CliGen.add_global_flag(#{long}) : validation proc must have a single input variable" unless validation.args.size == 1%}
{% arg = validation.args.first %}
{% raise "ERROR : CliGen.add_global_flag(#{long}) : validation proc input variable MUST be typed to match the flag type \"->(#{arg.name} : #{type}) : Bool { ... }\"" unless arg.restriction == type %}
{% end %}
{% unless on_match.nil? %}
{% raise "ERROR : CliGen.add_global_flag(#{long}) : Provided on_match must be a Proc" unless on_match.is_a? ProcLiteral %}
{% raise "ERROR : CliGen.add_global_flag(#{long}) : You must have arguments for on_match" if on_match.args.empty? %}
{% raise "ERROR : CliGen.add_global_flag(#{long}) : Your input argument must have a type" unless on_match.args.first.restriction %}
{% raise "ERROR : CliGen.add_global_flag(#{long}) : Your input argument must be the same type as your argument (#{type})" unless on_match.args.first.restriction == type %}
{% end %}
{% raise "ERROR : CliGen.add_global_flag(#{long}) : decription must be a StringLiteral" unless description.is_a? StringLiteral %}
{% if env_var %}
{% raise "ERROR : CliGen.add_global_flag(#{long}) : env_var must be a StringLiteral" unless env_var.is_a? StringLiteral %}
{% raise "ERROR : CliGen.add_global_flag(#{long}) : env_var cannot contain \"-\"'s please fix this" if env_var.includes?("-") %}
{% else %}
{% env_var = long.gsub(/--/, "").gsub(/-/,"_").upcase %}
{% end %}
::CliGen::GLOBAL_FLAGS << ::CliGen::Flag({{type}}).new(
var: "",
short: {{short}},
long: {{long}},
description: {{description}},
env_var: {{env_var}},
default: {{default}},
on_match: {% if on_match %} {{on_match}} {% else %} nil {% end %},
validate: {% if validation %} {{validation}} {% else %} nil {% end %}
)
end
end
+13
View File
@@ -0,0 +1,13 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
module CliGen
enum MatchType
FlagWithArg
FlagMultipleShort
ShortWithInlineArg
SubCommand
Help
NoMatch
end
end
+6
View File
@@ -0,0 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
module CliGen::Parsable
abstract def parse_args(args : Array(CliGen::Arg))
end
+45 -2
View File
@@ -1,4 +1,47 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
module CliGen::Regex
INPUT_DATETIME_REGEX = /^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$/
INPUT_DATE_REGEX = /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/
FLAG_REGEX=/^(-[a-zA-Z]|--[a-zA-Z-_0-9]+)$/
FLAG_WITH_ARG=/^(?<flag>(-[a-zA-Z]|--[a-zA-Z-_]+))="?(?<arg>\S+?)"?$/
FLAG_MULTIPLE_SHORT=/^-[a-zA-Z0-9]+$/
# ---------------------------------------------------------------------------
# Date/time components.
#
# These are building blocks ONLY — they are interpolated into the anchored
# matchers below and must stay unanchored. Interpolating a Regex renders it
# as `(?-imsx:...)`, so an anchor here would end up buried mid-pattern in the
# composites (`^(?-imsx:^...$)\s+...$`) and could never match.
#
# Never match user input against these directly — use the INPUT_DATE_*
# matchers, which are anchored.
# ---------------------------------------------------------------------------
# Hour is bounded 00-23 and minute 00-59 so the largest representable offset
# is 23:59 (86340s), which stays inside Time::Location.fixed's +/-24h limit.
# Without these bounds an offset like -9999 passes the match and then raises
# Time::Location::InvalidTimezoneOffsetError - a non-CliGen exception that
# escapes App#handle_command_raises and reaches the user as a stack trace.
TIMEZONE = /(?<timezone>(?<offset_sign>[-+])(?<offset_hour>[01][0-9]|2[0-3])(?<offset_minute>[0-5][0-9]))/
TIME = /(?<time>(?<hour>[0-9]{2}):(?<minute>[0-9]{2}):(?<second>[0-9]{2}))/
DATE = /(?<date>(?<year>[0-9]{4})-(?<month>[0-9]{2})-(?<day>[0-9]{2}))/
EPOCH = /@(?<epoch>[0-9]+)/
RELATIVE = /[+-][0-9]+\s+(seconds?|minutes?|hours?|days?|weeks?|months?|years?)/
# ---------------------------------------------------------------------------
# Relative Operation matcher - For use with CliGen::Timeparse::RelativeOperation
# ---------------------------------------------------------------------------
RELATIVE_OPERATION = /(?<sign>[+-])(?<quantity>[0-9]+)\s+(?<unit>seconds?|minutes?|hours?|days?|weeks?|months?|years?)/
# ---------------------------------------------------------------------------
# Date/time matchers - fully anchored so a partial match can't slip through.
# ---------------------------------------------------------------------------
INPUT_DATE_FULL = /^#{DATE}\s+#{TIME}(\s+#{TIMEZONE})?$/
INPUT_DATE_SIMPLE = /^#{DATE}(\s+#{TIMEZONE})?$/
INPUT_DATE_EPOCH = /^#{EPOCH}(\s+#{TIMEZONE})?$/
INPUT_RELATIVE_OPERATIONS = /^(?<operations>(#{RELATIVE}\s*)+)(\s+#{TIMEZONE})?$/
FLOAT = /^[-+]?[[:digit:]]+(\.[[:digit:]]+)?$/
UINT = /^[[:digit:]]+$/
INT = /^[-+]?[[:digit:]]+$/
end
+83
View File
@@ -0,0 +1,83 @@
Command: <%= @name %>
<%- unless @description.nil? -%>
Description: <%= @description %>
<%- end -%>
<%- unless @flags.empty? -%>
<%- len = @flags.map{|f| f.short.nil? ? f.long.size : "#{f.short},#{f.long}".size}.max + 5 -%>
Flags:
---------------------------------------------------------------
<%- @flags.each do |flag| -%>
<%- if flag.short.nil? -%>
<%- flags = [flag.long.strip] -%>
<%- else -%>
<%- flags = [flag.short,flag.long.strip] -%>
<%- end -%>
<%= "%-#{len}s %s" % [flags.join(","), flag.description.strip] %><%= flag.meta.options.nil? ? "" : " (valid: #{flag.meta.options.not_nil!.join(", ")})" %><%= flag.meta.default.empty? ? "" : " (default: #{flag.meta.default.not_nil!})" %>
<%- if verbose? -%>
<%= "%-#{len}s %s" % ["", "Type: #{flag.meta.type}"] %>
<%= "%-#{len}s %s" % ["", "ENV VAR: #{flag.env_var}"] %>
<%- unless flag.meta.format.nil? -%>
<%= "%-#{len}s %s" % ["", "Valid Format: #{flag.meta.format}"] %>
<%- end -%>
<%- if flag.meta.array -%>
<%= "%-#{len}s %s" % ["", "Delimiter: #{flag.delimiter}"] %>
<%- end -%>
<%- end -%>
<%- end -%>
<%- end -%>
<%- unless CliGen::GLOBAL_FLAGS.empty? -%>
<%- len = CliGen::GLOBAL_FLAGS.map{|f| f.short.nil? ? f.long.size : "#{f.short},#{f.long}".size}.max + 5 -%>
Global Flags
---------------------------------------------------------------
<%- CliGen::GLOBAL_FLAGS.each do |flag| -%>
<%- if flag.short.nil? -%>
<%- flags = [flag.long.strip] -%>
<%- else -%>
<%- flags = [flag.short,flag.long.strip] -%>
<%- end -%>
<%= "%-#{len}s %s" % [flags.join(","), flag.description.strip] %><%= flag.meta.options.nil? ? "" : " (valid: #{flag.meta.options.not_nil!.join(", ")})" %><%= flag.meta.default.empty? ? "" : " (default: #{flag.meta.default.not_nil!})" %>
<%- if verbose? -%>
<%= "%-#{len}s %s" % ["", "Type: #{flag.meta.type}"] %>
<%= "%-#{len}s %s" % ["", "ENV VAR: #{flag.env_var}"] %>
<%- unless flag.meta.format.nil? -%>
<%= "%-#{len}s %s" % ["", "Valid Format: #{flag.meta.format}"] %>
<%- end -%>
<%- if flag.meta.array -%>
<%= "%-#{len}s %s" % ["", "Delimiter: #{flag.delimiter}"] %>
<%- end -%>
<%- end -%>
<%- end -%>
<%- end -%>
<%- unless @commands.empty? -%>
Other Commands
---------------------------------------------------------------
<%- @commands.each do |command| -%>
<%= "%-#{len}s %s" % [ command.name, command.description ] %>
<%- end -%>
<%- end -%>
<%- if subcommands? -%>
SubCommands of <%= @name %>:
---------------------------------------------------------------
<%- subcommands.each do |cmd| -%>
<%= "%-#{len}s %s" % [cmd.name, cmd.description] %>
<%- end -%>
<%- cmds = subcommands.select{|c| ! c.examples.nil? } -%>
<%- unless cmds.empty? -%>
Examples:
---------------------------------------------------------------
<%- cmds.map(&.examples).flatten.each do |example| -%>
<%= example %>
<%- end -%>
<%- end -%>
<%- end -%>
Note: When wanting help output of any command you can provide the -h/--help flags or help command
+94
View File
@@ -0,0 +1,94 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
require "time"
require "./timeparse/relative_operation"
module CliGen::Timeparse
private def self.get_location(raw : String) : Time::Location
match = raw.match!(CliGen::Regex::TIMEZONE)
sign = match["offset_sign"] == "-" ? -1 : 1
hour = match["offset_hour"].to_i
min = match["offset_minute"].to_i
Time::Location.fixed(raw, sign * ((hour * 3600) + (min * 60)))
end
def self.parse(raw : String) : Time
raw = raw.strip
case raw
when CliGen::Regex::INPUT_DATE_EPOCH
match = raw.match!(CliGen::Regex::INPUT_DATE_EPOCH)
if match["timezone"]?
::Time.unix(match["epoch"].to_i).in(get_location(match["timezone"]))
else
::Time.parse!(raw, CliGen::Format::INPUT_EPOCH)
end
when CliGen::Regex::INPUT_DATE_FULL
match = raw.match!(CliGen::Regex::INPUT_DATE_FULL)
if match["timezone"]?
::Time.parse!(raw, CliGen::Format::INPUT_DATE_FULL)
else
::Time.parse_local(raw, CliGen::Format::INPUT_DATE_PARTIAL)
end
when CliGen::Regex::INPUT_DATE_SIMPLE
match = raw.match!(CliGen::Regex::INPUT_DATE_SIMPLE)
if match["timezone"]?
::Time.parse!(raw, CliGen::Format::INPUT_DATE_SIMPLE_WITH_TIMEZONE)
else
::Time.parse_local(raw, CliGen::Format::INPUT_DATE_SIMPLE)
end
when CliGen::Regex::INPUT_RELATIVE_OPERATIONS
match = raw.match!(CliGen::Regex::INPUT_RELATIVE_OPERATIONS)
ops = RelativeOperation.get_operations(match["operations"])
time = ::Time.local
if match["timezone"]?
time = time.in(get_location(match["timezone"]))
end
ops.each do |op|
time = op.apply(time)
end
time
else
raise CliGen::TimeParseError.new(<<-EOF
ERROR : invalid date/time format "#{raw}".
Valid are:
1) %Y-%m-%d %H:%M:%S %z
2) %Y-%m-%d %H:%M:%S
3) %Y-%m-%d %z
4) %Y-%m-%d
5) %s %z
6) %s
7) ([+-][0-9]+ (years|months|weeks|days|hours|minutes|seconds))+ %z
8) ([+-][0-9]+ [years|months|weeks|days|hours|minutes|seconds])+
Note on format:
# Timezone Offset (ex: -0500 == CST)
%z == [-+]([0-1][0-9]|2[0-3])[0-5][0-9]
# Year (ex: 2026)
%Y == [0-9]{4}
# month
%m == [0-9]{2}
# day
%d == [0-9]{2}
# hour
%H == [0-9]{2}
# minute
%S == [0-9]{2}
# epoch time
%s == @[0-9]+
EOF
)
end
end
end
+14
View File
@@ -0,0 +1,14 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
module CliGen::Timeparse
enum OperationUnit
YEAR
MONTH
WEEK
DAY
HOUR
MINUTE
SECOND
end
end
@@ -0,0 +1,47 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
require "time"
require "./operation_unit"
require "../regex"
module CliGen::Timeparse
struct RelativeOperation
getter sign : Int32
getter quantity : Int32
getter unit : CliGen::Timeparse::OperationUnit
def initialize(@sign, @quantity, @unit)
end
def apply(time : Time) : Time
{% begin %}
case @unit
{% for unit in CliGen::Timeparse::OperationUnit.constants %}
in OperationUnit::{{unit.id}}
time + (@sign * @quantity).{{unit.id.downcase}}
{% end %}
end
{% end %}
end
# Just handles retrieving the operations from a bare string and returning
# an array of them for use in applying them in a row
def self.get_operations(raw : String) : Array(RelativeOperation)
raw.scan(CliGen::Regex::RELATIVE_OPERATION).map{|match| from_regex(match)}
end
# Just an initializer from a regex match. Only callable internally
# so any operations must come from get_operations as that will handle
# parsing it for the user
private def self.from_regex(match : ::Regex::MatchData)
new(
sign: match["sign"] == "-" ? -1 : 1,
quantity: match["quantity"].to_i32,
# just in case the user provides the "s" (ex: "days", "hours", etc)
unit: OperationUnit.parse(match["unit"].chomp("s"))
)
end
end
end
+22
View File
@@ -0,0 +1,22 @@
!_TAG_EXTRA_DESCRIPTION anonymous /Include tags for non-named objects like lambda/
!_TAG_EXTRA_DESCRIPTION fileScope /Include tags of file scope/
!_TAG_EXTRA_DESCRIPTION pseudo /Include pseudo tags/
!_TAG_EXTRA_DESCRIPTION subparser /Include tags generated by subparsers/
!_TAG_FIELD_DESCRIPTION epoch /the last modified time of the input file (only for F\/file kind tag)/
!_TAG_FIELD_DESCRIPTION file /File-restricted scoping/
!_TAG_FIELD_DESCRIPTION input /input file/
!_TAG_FIELD_DESCRIPTION name /tag name/
!_TAG_FIELD_DESCRIPTION pattern /pattern/
!_TAG_FIELD_DESCRIPTION typeref /Type and name of a variable or typedef/
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_OUTPUT_EXCMD mixed /number, pattern, mixed, or combineV2/
!_TAG_OUTPUT_FILESEP slash /slash or backslash/
!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/
!_TAG_OUTPUT_VERSION 1.1 /current.age/
!_TAG_PATTERN_LENGTH_LIMIT 96 /0 for no limit/
!_TAG_PROC_CWD /home/tristan/Projects/Crystal/cligen/ //
!_TAG_PROGRAM_AUTHOR Universal Ctags Team //
!_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/
!_TAG_PROGRAM_URL https://ctags.io/ /official site/
!_TAG_PROGRAM_VERSION 6.2.1 /v6.2.1/
+56
View File
@@ -0,0 +1,56 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
#
# Manual harness for flag resolution + validation across every source a value
# can arrive from. Driven by ./utils/flag_matrix.sh; see that script for the expected
# results. Kept out of spec/ because each case needs its own process (env vars
# must be set before startup).
#
# ENV VAR NAMING - the two kinds of flag derive their names differently:
#
# global flag add_global_flag(..., long: "--retries") -> RETRIES
# derived from the long flag, minus the leading dashes
#
# command arg class Greet; argument(level : Int32 ...) -> GREET_LEVEL
# derived as <COMMAND>_<VAR>, see app/generate.cr
#
# The asymmetry is easy to trip over: exporting LEVEL=9 does nothing at all,
# because the command argument is bound to GREET_LEVEL.
require "cligen"
CliGen.add_global_flag(Int32,
long: "--retries",
short: "-r",
description: "retry count (global, validated 0..10, env: RETRIES)",
default: 3,
validation: ->(v : Int32) : Bool { v >= 0 && v <= 10 }
)
@[CliGen::CommandInfo(description: "flag resolution matrix")]
class Greet < CliGen::Command
argument(name : String = "world",
long: "--name",
description: "plain string, no validation (env: GREET_NAME)"
)
argument(level : Int32 = 1,
long: "--level",
description: "validated < 5 (env: GREET_LEVEL)",
validation: ->(v : Int32) : Bool { v < 5 }
)
private def retries : Int32
CliGen::GLOBAL_FLAGS
.find { |f| f.long_key == "--retries" }
.not_nil!
.as(CliGen::Flag(Int32))
.value!
end
def main
puts "retries=#{retries} level=#{@level} name=#{@name}"
end
end
CliGen::App.process
+87
View File
@@ -0,0 +1,87 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 Tristan Ancelet
#
# Runs flag_matrix.cr across every value source (default / env / CLI) for both
# a global flag and a command argument, and checks each result.
#
# Each case needs its own process because env vars must be set before startup,
# which is why this lives here rather than in spec/.
#
# ./utils/flag_matrix.sh (runnable from anywhere)
#
# Exits non-zero if any case does not match.
set -u
# Build from the PROJECT ROOT, not utils/. Two things depend on the CWD:
# - `require "cligen"` resolves via ./lib/cligen (the self-symlink)
# - command_node.cr renders ECR from the hardcoded relative path
# "lib/cligen/src/cligen/template/cmd_help.ecr"
# Building inside utils/ breaks both.
cd "$(dirname "$0")/.."
SRC=utils/flag_matrix.cr
BIN=utils/flag_matrix
pass=0
fail=0
echo "building..."
if ! crystal build "$SRC" -o "$BIN" 2>&1 | grep -v sframe; then :; fi
[ -x "$BIN" ] || { echo "build failed"; exit 1; }
echo
# check <label> <expected-substring> <env-assignments> <args...>
#
# Matches against the FULL output, not just the last line - multi-line output
# such as help text would otherwise only ever be compared against its footer.
# Only the last line is echoed back, to keep the report readable.
check() {
local label="$1" want="$2" envs="$3"; shift 3
local got shown
got=$(env $envs "$BIN" "$@" 2>&1)
shown=$(printf '%s' "$got" | tail -1)
if [[ "$got" == *"$want"* ]]; then
printf ' ok %-44s %s\n' "$label" "$shown"
pass=$((pass + 1))
else
printf ' FAIL %-44s %s\n' "$label" "$shown"
printf ' %-44s want substring: %s\n' "" "$want"
fail=$((fail + 1))
fi
}
echo "== defaults =="
check "no env, no flags" "retries=3 level=1 name=world" "" greet
echo
echo "== global flag: --retries (env RETRIES, valid 0..10) =="
check "env valid" "retries=7" "RETRIES=7" greet
check "env invalid -> rejected" "validation failed for --retries" "RETRIES=99" greet
check "cli valid" "retries=5" "" greet -r 5
check "cli invalid -> rejected" "validation failed for --retries" "" greet -r 99
check "cli overrides env" "retries=2" "RETRIES=8" greet -r 2
echo
echo "== command arg: --level (env GREET_LEVEL, valid < 5) =="
check "env valid" "level=3" "GREET_LEVEL=3" greet
check "env invalid -> rejected" "validation failed for --level" "GREET_LEVEL=9" greet
check "cli valid" "level=4" "" greet --level 4
check "cli invalid -> rejected" "validation failed for --level" "" greet --level 9
check "cli overrides env" "level=2" "GREET_LEVEL=4" greet --level 2
check "un-namespaced LEVEL ignored" "level=1" "LEVEL=9" greet
echo
echo "== command arg: --name (no validation) =="
check "env" "name=Bob" "GREET_NAME=Bob" greet
check "cli" "name=Alice" "" greet --name Alice
echo
echo "== help output =="
check "root help lists globals" "--retries" "" --help
check "command help lists args" "--level" "" greet --help
echo
echo "$pass passed, $fail failed"
rm -f "$BIN"
[ "$fail" -eq 0 ]