create cli.json
json
{
"name":"fd",
"version":"8.4.0",
"authors":["Anonymous <dnrops@anonymous.com>"],
"about":"A cli for find file",
"args":[
{
"arg":"--name",
"short":"-n",
"required":true,
"about":"about the file",
"takes_value":true,
"subcommands":[
{
"arg":"--remove",
"short":"-r",
"required":false,
"about":"remove or not",
"takes_value":false
}
]
},
{
"arg":"--file",
"short":"-f",
"required":true,
"about":"the file type",
"takes_value":true
}
]
}
cargo add cok
main.rs
```rust
fn main() {
use cok::cli::Cli;
Cli::loadfromjson("./cli.json");
let args = Cli::args();
}
a simple cli
fd 8.4.0
Anonymous dnrops@anonymous.com
A cli for find file
USAGE: OPTION ABOUT REQUIRED fd -n --name about the file true fd -f --file the file type true fd -h --help Prints help information
SUBCOMMANDS: OPTION SUBCOMMAND ABOUT REQUIRED fd -n --name -r --remove remove or not false
```