2个不稳定版本
0.3.1 | 2023年6月3日 |
---|---|
0.3.0 |
|
0.2.0 | 2023年6月2日 |
0.1.1 |
|
0.1.0 |
|
#976 in 文本处理
15KB
275 行
帮助Crafter
此crate提供了一种简单的方法来为您的CLI应用程序生成帮助信息。
快速开始
- 使用command()来链接命令以构建帮助信息
- 使用build()来生成帮助信息
示例
use help_crafter::enums::{DASHED, Parameter};
use help_crafter::HelpMessageBuilder;
let help = HelpMessageBuilder::default()
.command("i", "index", Parameter::NO, "index", DASHED::YES)
.command(
"k",
"kill",
Parameter::REQUIRED("sessions_id"),
"the big brown fox jumps over the lazy dog the big brown fox",
DASHED::YES,
)
.command(
"",
"rub",
Parameter::OPTIONAL("something"),
"rub something",
DASHED::NO,
)
.command(
"t",
"",
Parameter::REQUIRED("something"),
"t something",
DASHED::YES,
)
.command(
"o",
"",
Parameter::OPTIONAL("something"),
"o something",
DASHED::NO,
)
.build();
lib.rs
:
帮助Crafter
此crate提供了一种简单的方法来为您的CLI应用程序生成帮助信息。
快速开始
示例
use help_crafter::enums::{DASHED, Parameter};
use help_crafter::HelpMessageBuilder;
let help = HelpMessageBuilder::default()
.command("i", "index", Parameter::NO, "index", DASHED::YES)
.command(
"k",
"kill",
Parameter::REQUIRED("sessions_id"),
"the big brown fox jumps over the lazy dog the big brown fox",
DASHED::YES,
)
.command(
"",
"rub",
Parameter::OPTIONAL("something"),
"rub something",
DASHED::NO,
)
.command(
"t",
"",
Parameter::REQUIRED("something"),
"t something",
DASHED::YES,
)
.command(
"o",
"",
Parameter::OPTIONAL("something"),
"o something",
DASHED::NO,
)
.build();
返回以下信息。
-i --index index
-k --kill <sessions_id> the big brown fox jumps over the lazy
dog the big brown fox
rub [something] rub something
-t <something> t something
o [something] o something