2022-07-19 18:29:31 +00:00
|
|
|
**This requires enabling the [`derive` feature flag][crate::_features].**
|
2021-12-08 22:46:49 +00:00
|
|
|
|
2022-03-14 14:43:17 +00:00
|
|
|
Help:
|
2022-01-05 16:54:33 +00:00
|
|
|
```console
|
2022-03-14 14:37:52 +00:00
|
|
|
$ typed-derive --help
|
2022-09-07 16:03:55 +00:00
|
|
|
Usage: typed-derive[EXE] [OPTIONS]
|
2021-12-08 01:01:55 +00:00
|
|
|
|
2022-08-26 14:40:23 +00:00
|
|
|
Options:
|
2022-10-05 23:56:37 +00:00
|
|
|
-O <OPTIMIZATION> Implicitly using `std::str::FromStr`
|
|
|
|
-I <DIR> Allow invalid UTF-8 paths
|
|
|
|
--bind <BIND> Handle IP addresses
|
|
|
|
--sleep <SLEEP> Allow human-readable durations
|
|
|
|
-D <DEFINES> Hand-written parser for tuples
|
|
|
|
--port <PORT> Support for discrete numbers [default: 22] [possible values: 22, 80]
|
|
|
|
--log-level <LOG_LEVEL> Support enums from a foreign crate that don't implement `ValueEnum` [default: info] [possible values: info, debug, info, warn, error]
|
2023-01-03 16:49:43 +00:00
|
|
|
-h, --help Print help
|
2022-01-05 16:54:33 +00:00
|
|
|
|
2022-03-14 14:43:17 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Optimization-level (number)
|
|
|
|
```console
|
|
|
|
$ typed-derive -O 1
|
2022-10-05 23:56:37 +00:00
|
|
|
Args { optimization: Some(1), include: None, bind: None, sleep: None, defines: [], port: 22, log_level: Info }
|
2022-03-14 14:43:17 +00:00
|
|
|
|
|
|
|
$ typed-derive -O plaid
|
|
|
|
? failed
|
2023-01-03 16:22:40 +00:00
|
|
|
error: invalid value 'plaid' for '-O <OPTIMIZATION>': invalid digit found in string
|
2022-03-14 14:43:17 +00:00
|
|
|
|
2023-01-03 19:22:35 +00:00
|
|
|
For more information, try '--help'.
|
2022-03-14 14:43:17 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
|
2022-03-14 14:45:43 +00:00
|
|
|
Include (path)
|
|
|
|
```console
|
|
|
|
$ typed-derive -I../hello
|
2022-10-05 23:56:37 +00:00
|
|
|
Args { optimization: None, include: Some("../hello"), bind: None, sleep: None, defines: [], port: 22, log_level: Info }
|
2022-03-14 14:53:31 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
IP Address
|
|
|
|
```console
|
|
|
|
$ typed-derive --bind 192.0.0.1
|
2022-10-05 23:56:37 +00:00
|
|
|
Args { optimization: None, include: None, bind: Some(192.0.0.1), sleep: None, defines: [], port: 22, log_level: Info }
|
2022-03-14 14:53:31 +00:00
|
|
|
|
|
|
|
$ typed-derive --bind localhost
|
|
|
|
? failed
|
2023-01-03 16:22:40 +00:00
|
|
|
error: invalid value 'localhost' for '--bind <BIND>': invalid IP address syntax
|
2022-03-14 14:53:31 +00:00
|
|
|
|
2023-01-03 19:22:35 +00:00
|
|
|
For more information, try '--help'.
|
2022-03-14 14:49:46 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
Time
|
|
|
|
```console
|
|
|
|
$ typed-derive --sleep 10s
|
2022-10-05 23:56:37 +00:00
|
|
|
Args { optimization: None, include: None, bind: None, sleep: Some(Duration(10s)), defines: [], port: 22, log_level: Info }
|
2022-03-14 14:49:46 +00:00
|
|
|
|
|
|
|
$ typed-derive --sleep forever
|
|
|
|
? failed
|
2023-01-03 16:22:40 +00:00
|
|
|
error: invalid value 'forever' for '--sleep <SLEEP>': expected number at 0
|
2022-03-14 14:49:46 +00:00
|
|
|
|
2023-01-03 19:22:35 +00:00
|
|
|
For more information, try '--help'.
|
2022-03-14 14:45:43 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
|
2022-03-14 14:43:17 +00:00
|
|
|
Defines (key-value pairs)
|
|
|
|
```console
|
2022-03-14 14:37:52 +00:00
|
|
|
$ typed-derive -D Foo=10 -D Alice=30
|
2022-10-05 23:56:37 +00:00
|
|
|
Args { optimization: None, include: None, bind: None, sleep: None, defines: [("Foo", 10), ("Alice", 30)], port: 22, log_level: Info }
|
2022-01-05 16:54:33 +00:00
|
|
|
|
2022-03-14 14:37:52 +00:00
|
|
|
$ typed-derive -D Foo
|
2021-12-08 01:01:55 +00:00
|
|
|
? failed
|
2023-01-03 16:22:40 +00:00
|
|
|
error: invalid value 'Foo' for '-D <DEFINES>': invalid KEY=value: no `=` found in `Foo`
|
2021-12-08 01:01:55 +00:00
|
|
|
|
2023-01-03 19:22:35 +00:00
|
|
|
For more information, try '--help'.
|
2022-01-05 16:54:33 +00:00
|
|
|
|
2022-03-14 14:37:52 +00:00
|
|
|
$ typed-derive -D Foo=Bar
|
2021-12-08 01:01:55 +00:00
|
|
|
? failed
|
2023-01-03 16:22:40 +00:00
|
|
|
error: invalid value 'Foo=Bar' for '-D <DEFINES>': invalid digit found in string
|
2021-12-08 01:01:55 +00:00
|
|
|
|
2023-01-03 19:22:35 +00:00
|
|
|
For more information, try '--help'.
|
2022-01-05 16:54:33 +00:00
|
|
|
|
2021-12-08 01:01:55 +00:00
|
|
|
```
|
2022-10-05 23:56:37 +00:00
|
|
|
|
|
|
|
Discrete numbers
|
|
|
|
```console
|
|
|
|
$ typed-derive --port 22
|
|
|
|
Args { optimization: None, include: None, bind: None, sleep: None, defines: [], port: 22, log_level: Info }
|
|
|
|
|
|
|
|
$ typed-derive --port 80
|
|
|
|
Args { optimization: None, include: None, bind: None, sleep: None, defines: [], port: 80, log_level: Info }
|
|
|
|
|
|
|
|
$ typed-derive --port
|
|
|
|
? failed
|
2023-01-06 23:01:34 +00:00
|
|
|
error: a value is required for '--port <PORT>' but none was supplied
|
2022-10-05 23:56:37 +00:00
|
|
|
[possible values: 22, 80]
|
|
|
|
|
2023-01-03 19:22:35 +00:00
|
|
|
For more information, try '--help'.
|
2022-10-05 23:56:37 +00:00
|
|
|
|
|
|
|
$ typed-derive --port 3000
|
|
|
|
? failed
|
2023-01-06 23:01:34 +00:00
|
|
|
error: invalid value '3000' for '--port <PORT>'
|
2022-10-05 23:56:37 +00:00
|
|
|
[possible values: 22, 80]
|
|
|
|
|
2023-01-03 19:22:35 +00:00
|
|
|
For more information, try '--help'.
|
2022-10-05 23:56:37 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
Enums from crates that can't implement `ValueEnum`
|
|
|
|
```console
|
|
|
|
$ typed-derive --log-level debug
|
|
|
|
Args { optimization: None, include: None, bind: None, sleep: None, defines: [], port: 22, log_level: Debug }
|
|
|
|
|
|
|
|
$ typed-derive --log-level error
|
|
|
|
Args { optimization: None, include: None, bind: None, sleep: None, defines: [], port: 22, log_level: Error }
|
|
|
|
|
|
|
|
$ typed-derive --log-level
|
|
|
|
? failed
|
2023-01-06 23:01:34 +00:00
|
|
|
error: a value is required for '--log-level <LOG_LEVEL>' but none was supplied
|
2022-10-05 23:56:37 +00:00
|
|
|
[possible values: info, debug, info, warn, error]
|
|
|
|
|
2023-01-03 19:22:35 +00:00
|
|
|
For more information, try '--help'.
|
2022-10-05 23:56:37 +00:00
|
|
|
|
|
|
|
$ typed-derive --log-level critical
|
|
|
|
? failed
|
2023-01-06 23:01:34 +00:00
|
|
|
error: invalid value 'critical' for '--log-level <LOG_LEVEL>'
|
2022-10-05 23:56:37 +00:00
|
|
|
[possible values: info, debug, info, warn, error]
|
|
|
|
|
2023-01-03 19:22:35 +00:00
|
|
|
For more information, try '--help'.
|
2022-10-05 23:56:37 +00:00
|
|
|
|
|
|
|
```
|