-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.go
More file actions
36 lines (28 loc) · 853 Bytes
/
example.go
File metadata and controls
36 lines (28 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Example provides an example command line application built using go-commando. An action has been configured to print
// both arguments and options to Stdout.
package main
import (
"fmt"
"github.com/J-R-Oliver/go-commando"
)
func main() {
argOptPrinter := func(arguments []string, options map[string]string) {
fmt.Println("Arguments:")
for i, a := range arguments {
fmt.Printf("\tindex: %d, argument: %s\n", i, a)
}
fmt.Println("Options:")
for k, v := range options {
fmt.Printf("\tkey: %s, option: %s\n", k, v)
}
}
program := commando.NewProgram()
program.
Name("file-splitter").
Description("CLI to split file written in go.").
Version("1.0.0").
Option("i", "input", "input", "Input file", "./input.txt").
Option("o", "output", "output", "Output file", "./output.txt").
Action(argOptPrinter).
Parse()
}