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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
use clap::{App, Arg, SubCommand};
pub fn build_cli<'a>(app: &str, home: &'a str, version: &'a str) -> App<'a, 'a> {
App::new(app)
.about("Handlebars template utility. Pass in string (url format), json or yaml file as data input along with input/output file names")
.author("Chris Jones")
.version(version)
.after_help("For more information about a specific command, try `lsiotemplate <command> --help`\nSource code for lsiotemplate available at: https://github.com/lambdastackio/lsiotemplate")
.arg(Arg::with_name("config")
.short("c")
.long("config")
.value_name("FILE")
.default_value(home)
.help("Sets a custom config file.")
.takes_value(true))
.arg(Arg::with_name("data")
.short("d")
.long("data")
.value_name("data in json format")
.help("pass in data in json format")
.takes_value(true))
.arg(Arg::with_name("input")
.short("i")
.long("input")
.value_name("template input string")
.help("pass in a template input string instead of a file name")
.takes_value(true))
.arg(Arg::with_name("output")
.short("o")
.long("output")
.value_name("FILE")
.help("Path to output file. If not specified then output will be to stdout by default")
.takes_value(true))
.arg(Arg::with_name("file")
.short("f")
.long("file")
.value_name("FILE")
.help("Path to data input file. Data (-d) will supercede this option if present")
.takes_value(true))
.arg(Arg::with_name("template")
.short("t")
.long("template")
.value_name("FILE")
.help("Path to template input file. Input (-i) will supercede this option if present")
.takes_value(true))
.arg(Arg::with_name("output-format")
.short("u")
.long("output-format")
.default_value("file")
.value_name("file, pretty-json, json, plain or serialize")
.help("Specifies the output to stdout (and disk in some cases). Options are file, json, none, noneall, pretty-json, plain, serialize")
.takes_value(true))
.arg(Arg::with_name("generate-bash-completions")
.short("g")
.long("generate-bash-completions")
.help("Outputs bash completions"))
.arg(Arg::with_name("proxy")
.short("p")
.long("proxy")
.value_name("URL:<port>")
.help("Sets a custom proxy URL:<port>. Default is to use http(s)_proxy and no_proxy for URL data request only")
.takes_value(true))
.arg(Arg::with_name("output-color")
.short("l")
.long("output-color")
.default_value("green")
.value_name("green or red or blue or yellow or white or normal")
.help("Specifies the output color.")
.takes_value(true))
.arg(Arg::with_name("quiet")
.short("q")
.long("quiet")
.help("No output to stdout is produced"))
.subcommand(SubCommand::with_name("json")
.about("json format of input data"))
.subcommand(SubCommand::with_name("yaml")
.about("yaml format of input data"))
}