File tree Expand file tree Collapse file tree 1 file changed +98
-0
lines changed
Expand file tree Collapse file tree 1 file changed +98
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,104 @@ line interfaces in a composable way.
77
88## Usage
99
10+ ##### Simple Hello World
11+
12+ ``` swift
13+ import Commander
14+
15+ let main = command {
16+ print (" Hello World" )
17+ }
18+
19+ main.run ()
20+ ```
21+
22+ ##### Type-safe argument handling
23+
24+ ``` swift
25+ command { (hostname :String , port :Int ) in
26+ print (" Connecting to \( hostname ) on port \( port ) ..." )
27+ }
28+ ```
29+
30+ ##### Grouping commands
31+
32+ You can group a collection of commands together.
33+
34+ ``` swift
35+ Group {
36+ $0 .command (" login" ) { (name :String ) in
37+ print (" Hello \( name ) " )
38+ }
39+
40+ $0 .command (" logout" ) {
41+ print (" Goodbye." )
42+ }
43+ }
44+ ```
45+
46+ Usage:
47+
48+ ``` shell
49+ $ tool login Kyle
50+ Hello Kyle
51+ $ tool logout
52+ Goodbye.
53+ ```
54+
55+ #### Using the argument parser
56+
57+ You can get hold of the argument parser to do custom argument handling
58+
59+ ``` swift
60+ command { (name :String , parser :ArgumentParser) in
61+ if parser.hasOption (" verbose" ) {
62+ print (" Verbose mode enabled" )
63+ }
64+
65+ print (" Hello \( name ) " )
66+ }
67+ ```
68+
69+ ``` shell
70+ $ tool Kyle --verbose
71+ Verbose mode enabled
72+ Hello Kyle
73+ ```
74+
75+ ### Examples tools using Commander
76+
77+ - [ QueryKit] ( https://github.com/QueryKit/querykit-cli ) via CocoaPods Rome
78+
79+ ## Installation
80+
81+ You can install Commander in many ways, such as with CocoaPods, Carthage or as
82+ a sub-project.
83+
84+ ### CocoaPods
85+
86+ ``` ruby
87+ pod ' Commander'
88+ ```
89+
90+ #### Cato
91+
92+ The simplest way to build a Swift script that uses Commander would be to use
93+ [ cato] ( https://github.com/neonichu/cato ) . Cato will automatically download
94+ Commander behind the scenes.
95+
96+ ``` swift
97+ #!/ usr/ bin/ env cato
98+
99+ import Commander
100+
101+ let main = command {
102+ print (" Hello World" )
103+ }
104+
105+ main.run ()
106+ ```
107+
10108## License
11109
12110Commander is available under the BSD license. See the [ LICENSE file] ( LICENSE )
You can’t perform that action at this time.
0 commit comments