]>
Commit | Line | Data |
---|---|---|
6522a427 EL |
1 | **This requires enabling the [`derive` feature flag][crate::_features].** |
2 | ||
3 | Help: | |
4 | ```console | |
5 | $ typed-derive --help | |
6 | Usage: typed-derive[EXE] [OPTIONS] | |
7 | ||
8 | Options: | |
9 | -O <OPTIMIZATION> Implicitly using `std::str::FromStr` | |
10 | -I <DIR> Allow invalid UTF-8 paths | |
11 | --bind <BIND> Handle IP addresses | |
12 | --sleep <SLEEP> Allow human-readable durations | |
13 | -D <DEFINES> Hand-written parser for tuples | |
14 | --port <PORT> Support for discrete numbers [default: 22] [possible values: 22, 80] | |
15 | --log-level <LOG_LEVEL> Support enums from a foreign crate that don't implement `ValueEnum` [default: info] [possible values: info, debug, info, warn, error] | |
16 | -h, --help Print help | |
17 | ||
18 | ``` | |
19 | ||
20 | Optimization-level (number) | |
21 | ```console | |
22 | $ typed-derive -O 1 | |
23 | Args { optimization: Some(1), include: None, bind: None, sleep: None, defines: [], port: 22, log_level: Info } | |
24 | ||
25 | $ typed-derive -O plaid | |
26 | ? failed | |
27 | error: invalid value 'plaid' for '-O <OPTIMIZATION>': invalid digit found in string | |
28 | ||
29 | For more information, try '--help'. | |
30 | ||
31 | ``` | |
32 | ||
33 | Include (path) | |
34 | ```console | |
35 | $ typed-derive -I../hello | |
36 | Args { optimization: None, include: Some("../hello"), bind: None, sleep: None, defines: [], port: 22, log_level: Info } | |
37 | ||
38 | ``` | |
39 | ||
40 | IP Address | |
41 | ```console | |
42 | $ typed-derive --bind 192.0.0.1 | |
43 | Args { optimization: None, include: None, bind: Some(192.0.0.1), sleep: None, defines: [], port: 22, log_level: Info } | |
44 | ||
45 | $ typed-derive --bind localhost | |
46 | ? failed | |
47 | error: invalid value 'localhost' for '--bind <BIND>': invalid IP address syntax | |
48 | ||
49 | For more information, try '--help'. | |
50 | ||
51 | ``` | |
52 | ||
53 | Time | |
54 | ```console | |
55 | $ typed-derive --sleep 10s | |
56 | Args { optimization: None, include: None, bind: None, sleep: Some(Duration(10s)), defines: [], port: 22, log_level: Info } | |
57 | ||
58 | $ typed-derive --sleep forever | |
59 | ? failed | |
60 | error: invalid value 'forever' for '--sleep <SLEEP>': expected number at 0 | |
61 | ||
62 | For more information, try '--help'. | |
63 | ||
64 | ``` | |
65 | ||
66 | Defines (key-value pairs) | |
67 | ```console | |
68 | $ typed-derive -D Foo=10 -D Alice=30 | |
69 | Args { optimization: None, include: None, bind: None, sleep: None, defines: [("Foo", 10), ("Alice", 30)], port: 22, log_level: Info } | |
70 | ||
71 | $ typed-derive -D Foo | |
72 | ? failed | |
73 | error: invalid value 'Foo' for '-D <DEFINES>': invalid KEY=value: no `=` found in `Foo` | |
74 | ||
75 | For more information, try '--help'. | |
76 | ||
77 | $ typed-derive -D Foo=Bar | |
78 | ? failed | |
79 | error: invalid value 'Foo=Bar' for '-D <DEFINES>': invalid digit found in string | |
80 | ||
81 | For more information, try '--help'. | |
82 | ||
83 | ``` | |
84 | ||
85 | Discrete numbers | |
86 | ```console | |
87 | $ typed-derive --port 22 | |
88 | Args { optimization: None, include: None, bind: None, sleep: None, defines: [], port: 22, log_level: Info } | |
89 | ||
90 | $ typed-derive --port 80 | |
91 | Args { optimization: None, include: None, bind: None, sleep: None, defines: [], port: 80, log_level: Info } | |
92 | ||
93 | $ typed-derive --port | |
94 | ? failed | |
95 | error: a value is required for '--port <PORT>' but none was supplied | |
96 | [possible values: 22, 80] | |
97 | ||
98 | For more information, try '--help'. | |
99 | ||
100 | $ typed-derive --port 3000 | |
101 | ? failed | |
102 | error: invalid value '3000' for '--port <PORT>' | |
103 | [possible values: 22, 80] | |
104 | ||
105 | For more information, try '--help'. | |
106 | ||
107 | ``` | |
108 | ||
109 | Enums from crates that can't implement `ValueEnum` | |
110 | ```console | |
111 | $ typed-derive --log-level debug | |
112 | Args { optimization: None, include: None, bind: None, sleep: None, defines: [], port: 22, log_level: Debug } | |
113 | ||
114 | $ typed-derive --log-level error | |
115 | Args { optimization: None, include: None, bind: None, sleep: None, defines: [], port: 22, log_level: Error } | |
116 | ||
117 | $ typed-derive --log-level | |
118 | ? failed | |
119 | error: a value is required for '--log-level <LOG_LEVEL>' but none was supplied | |
120 | [possible values: info, debug, info, warn, error] | |
121 | ||
122 | For more information, try '--help'. | |
123 | ||
124 | $ typed-derive --log-level critical | |
125 | ? failed | |
126 | error: invalid value 'critical' for '--log-level <LOG_LEVEL>' | |
127 | [possible values: info, debug, info, warn, error] | |
128 | ||
129 | For more information, try '--help'. | |
130 | ||
131 | ``` |