Committing before help rework

This commit is contained in:
2026-09-05 13:19:55 -05:00
parent 4cce5cc45c
commit 3fa77f5707
105 changed files with 22505 additions and 684 deletions
+55
View File
@@ -0,0 +1,55 @@
# CliGen::Command Macros
## TOC
- [Overview](#Overview)
## Overview
This page is dedicated to discussing the macros associated & embedded in the `CliGen::Command` class.
## Macros
### argument
This macro used in a Command subclass does one thing and well. It helps define an instance variable with valid annotation keys and helps debug any misconfigurations before you experience them via the compiler and/or during runtime.
```crystal
require "cligen"
@[CliGen::CommandInfo(description: "Thing")]
class MyClass << CliGen::Command
argument(myvar : String = "abc",
description: "This var changes the printed string",
options: %w[ abc def ghi ]
)
def main
puts "Chosen string : %s" % @myvar
end
end
```
*Example: String Argument*
The above essentialy expands out to the following
```crystal
require "cligen"
@[CliGen::CommandInfo(description: "Thing")]
class MyClass << CliGen::Command
@[CliGen::Argument(description: "This var changes the printed string", options: %w[ abc def ghi ])]
@myvar : String = "abc"
def main
puts "Chosen string : %s" % @myvar
end
end
```
It simply provides you a user friendly "DSL" to define a (sometimes) extensive annotation that would be a PITA to do by hand.
However, the use of the macro has much more attributed to it than just doing this.
For a more detailed walkthrough & it's required keys go to the [argument macro doc](./Macro/argument.md).