You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+25-12Lines changed: 25 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,29 +1,44 @@
1
1
# CLI.cr
2
-
Yet another Crystal command line interface library.
2
+
3
+
Yet another command line interface library for Crystal. Based on [spf13/cobra](https://github.com/spf13/cobra), CLI.cr is built to be almost entirely modular, giving you absolute control over almost everything without the need for embedded macros - there isn't even a default help command or flag!
3
4
4
5
## Installation
6
+
5
7
1. Add the dependency to your `shard.yml`:
6
8
```yaml
7
9
dependencies:
8
10
cli:
9
11
github: devnote-dev/cli.cr
12
+
branch: stable
10
13
```
11
14
12
15
2. Run `shards install`
13
16
14
17
## Usage
18
+
15
19
```crystal
16
20
require "cli"
17
21
18
22
class MainCmd < CLI::Command
19
-
def setup
23
+
def setup : Nil
20
24
@name = "greet"
21
-
@description = "Greets a person"
25
+
description = "Greets a person"
22
26
add_argument "name", desc: "the name of person to greet", required: true
23
-
add_option "caps", short: "c", desc: "greet with capitals"
27
+
add_option 'c', "caps", desc: "greet with capitals"
28
+
add_option 'h', "help", desc: "sends help information"
29
+
end
30
+
31
+
def pre_run(args, options)
32
+
if options.has? "help"
33
+
puts help_template # generated using CLI::Formatter
0 commit comments