diff --git a/src/args/cmd/news.rs b/src/args/cmd/news.rs index 6e25a2c..f395935 100644 --- a/src/args/cmd/news.rs +++ b/src/args/cmd/news.rs @@ -4,7 +4,7 @@ use clap::Parser; pub struct Opt { #[arg(verbatim_doc_comment)] /// Show news list, order by time in DESC - /// Example: cnb news --list + /// Example: cnb news --list #[arg(long)] #[arg(short = 'l')] pub list: bool, diff --git a/src/args/cmd/post.rs b/src/args/cmd/post.rs index 399cdfc..29bc663 100644 --- a/src/args/cmd/post.rs +++ b/src/args/cmd/post.rs @@ -2,42 +2,44 @@ use clap::{Parser, Subcommand}; #[derive(Parser, Debug)] pub struct Opt { - #[arg(verbatim_doc_comment)] + #[clap(verbatim_doc_comment)] /// Show title and content of a specific post - /// Example: cnb --id 114514 post --show - /// You should also specify the id of the post via --id + /// Example: cnb --id 114514 post --show + /// You should also specify the id of the post via --id #[arg(long)] #[arg(short = 's')] pub show: bool, #[arg(verbatim_doc_comment)] /// Show metadata of a specific post - /// Example: cnb --id 114514 post --show-meta - /// You should also specify the id of the post via --id + /// Example: cnb --id 114514 post --show-meta + /// You should also specify the id of the post via --id #[arg(long)] #[arg(short = 'm')] pub show_meta: bool, #[arg(verbatim_doc_comment)] /// Show post list, order by time in DESC - /// Example: cnb post --list - /// should in range [0,100] - /// If greater than 100, it will be set to 100 + /// Example: cnb post --list + /// should in range [0,100] + /// If greater than 100, it will be set to 100 #[arg(long)] #[arg(short = 'l')] pub list: bool, #[arg(verbatim_doc_comment)] /// Delete post - /// Example: cnb --id 114514 post --delete - /// You should also specify the id of the post via --id + /// Example: cnb --id 114514 post --delete + /// You should also specify the id of the post via --id + /// * #[arg(long)] #[arg(visible_alias = "del")] pub delete: bool, #[arg(verbatim_doc_comment)] /// Search post by keyword and output the post id list that matches - /// Example: cnb post --search 'Hello world' + /// Example: cnb post --search 'Hello world' + /// * #[arg(long)] #[arg(short = 'f')] #[arg(visible_alias = "find")] @@ -50,53 +52,59 @@ pub struct Opt { #[derive(Debug, Subcommand)] pub enum Cmd { + #[clap(verbatim_doc_comment)] /// Create post /// Example: cnb post create --title 'Title' --body 'Body' + /// * #[clap(visible_alias = "c")] Create { #[arg(verbatim_doc_comment)] /// Set post title - /// Example: cnb post create --title 'Title' --body 'Body' + /// Example: cnb post create --title 'Title' --body 'Body' #[arg(long)] #[arg(value_name = "TITLE")] title: String, #[arg(verbatim_doc_comment)] /// Set post body - /// Example: cnb post create --title 'Title' --body 'Body' + /// Example: cnb post create --title 'Title' --body 'Body' #[arg(long)] #[arg(value_name = "BODY")] body: String, #[arg(verbatim_doc_comment)] /// Set post status to publish - /// Example: cnb post create --title 'Title' --body 'Body' --publish + /// Example: cnb post create --title 'Title' --body 'Body' --publish + /// * #[arg(long)] #[arg(visible_alias = "pub")] publish: bool, }, + #[clap(verbatim_doc_comment)] /// Update post /// Example: cnb --id 114514 post update --title 'Title' - /// You should also specify the id of the post via --id + /// You should also specify the id of the post via --id + /// * #[clap(visible_alias = "u")] Update { #[arg(verbatim_doc_comment)] /// Set post title - /// Example: cnb --id 114514 post update --title 'Title' + /// Example: cnb --id 114514 post update --title 'Title' #[arg(long)] #[arg(value_name = "TITLE")] title: Option, #[arg(verbatim_doc_comment)] /// Set post body - /// Example: cnb --id 114514 post update --body 'Body' + /// Example: cnb --id 114514 post update --body 'Body' #[arg(long)] #[arg(value_name = "BODY")] body: Option, #[arg(verbatim_doc_comment)] /// Set post publish state - /// Example: cnb --id 114514 post update --publish true + /// Example: cnb --id 114514 post update --publish true + /// * #[arg(long)] #[arg(value_name = "BOOL")] #[arg(visible_alias = "pub")] diff --git a/src/args/cmd/user.rs b/src/args/cmd/user.rs index 00a31cb..0d8638e 100644 --- a/src/args/cmd/user.rs +++ b/src/args/cmd/user.rs @@ -4,22 +4,22 @@ use clap::Parser; pub struct Opt { #[arg(verbatim_doc_comment)] /// Login with your personal access token (PAT) - /// Example: cnb user --login 'FOOBARBAZ' - /// PAT will be saved in ~/.cnbrc - /// You can create PAT in https://account.cnblogs.com/tokens + /// Example: cnb user --login 'FOOBARBAZ' + /// PAT will be saved in ~/.cnbrc + /// You can create PAT in https://account.cnblogs.com/tokens #[arg(long)] #[arg(value_name = "PAT")] pub login: Option, #[arg(verbatim_doc_comment)] /// Logout and remove ~/.cnbrc - /// Example: cnb user --logout + /// Example: cnb user --logout #[arg(long)] pub logout: bool, #[arg(verbatim_doc_comment)] /// Show user info - /// Example: cnb user --info + /// Example: cnb user --info #[arg(long)] #[arg(short = 'i')] pub info: bool, diff --git a/src/args/mod.rs b/src/args/mod.rs index 2fb5977..9ca96a8 100644 --- a/src/args/mod.rs +++ b/src/args/mod.rs @@ -19,21 +19,21 @@ pub struct Args { #[arg(verbatim_doc_comment)] /// Provide ID required by other options - /// Example: cnb --id 114514 post --show + /// Example: cnb --id 114514 post --show #[arg(long)] pub id: Option, #[arg(verbatim_doc_comment)] /// Reverse list output - /// Example: cnb --rev ing --list + /// Example: cnb --rev ing --list #[arg(long)] pub rev: bool, #[arg(verbatim_doc_comment)] /// Skip items while request list - /// Example: cnb --skip 2 ing --list - /// Use this option to save network I/O if some items of the list output are not needed - /// If this option is required but not specified, it will be set to 0 + /// Example: cnb --skip 2 ing --list + /// Use this option to save network I/O if some items of the list output are not needed + /// If this option is required but not specified, it will be set to 0 #[arg(long)] #[arg(short = 's')] #[arg(value_name = "LENGTH")] @@ -41,11 +41,11 @@ pub struct Args { #[arg(verbatim_doc_comment)] /// Take items while request list - /// Example: cnb --take 2 ing --list - /// Use this option to save network I/O if only a subset of the list output are required - /// should be in the range [0,100] - /// If is greater than 100, it will be set to 100 - /// If this option is required but not specified, it will be set to 8 + /// Example: cnb --take 2 ing --list + /// Use this option to save network I/O if only a subset of the list output are required + /// should be in the range [0,100] + /// If is greater than 100, it will be set to 100 + /// If this option is required but not specified, it will be set to 8 #[arg(long)] #[arg(short = 't')] #[arg(value_name = "LENGTH")] @@ -53,24 +53,27 @@ pub struct Args { #[arg(verbatim_doc_comment)] /// Execute with specific PAT - /// Example: cnb --with-pat 'FOOBARBAZ' post --list - /// Your PAT in ~/.cnbrc will be ignored in this execution if it exists - /// Please login if you don't want to input PAT everytime, try 'cnb user --help' for more details + /// Example: cnb --with-pat 'FOOBARBAZ' post --list + /// Your PAT in ~/.cnbrc will be ignored in this execution if it exists + /// Please login if you don't want to input PAT everytime, try 'cnb user --help' for more details #[arg(long)] #[arg(value_name = "PAT")] pub with_pat: Option, #[arg(verbatim_doc_comment)] /// Execute in debug mode, this will print some messages for the developer - /// Example: cnb --debug ing --list - /// THIS OPTION IS UNSTABLE FOREVER and any output from it may change in the future - /// You should NEVER rely on the output while you turn this option on + /// Example: cnb --debug ing --list + /// THIS OPTION IS UNSTABLE FOREVER and any output from it may change in the future + /// You should NEVER rely on the output while you turn this option on + /// * #[arg(long)] #[clap(visible_alias = "dbg")] pub debug: bool, #[arg(verbatim_doc_comment)] /// Configure the output style + /// Example: cnb --style json ing list + /// * #[arg(long)] #[arg(value_enum)] #[arg(hide_possible_values = true)] @@ -80,7 +83,8 @@ pub struct Args { #[arg(verbatim_doc_comment)] /// Fail if error occurred - /// Example: cnb --fail-on-error ing --list + /// Example: cnb --fail-on-error ing --list + /// * #[arg(long)] #[clap(visible_alias = "foe")] #[arg(default_value_t = false)] @@ -88,7 +92,8 @@ pub struct Args { #[arg(verbatim_doc_comment)] /// Suppress all output - /// Example: cnb --quiet ing --list + /// Example: cnb --quiet ing --list + /// * #[arg(long)] #[clap(visible_alias = "silent")] #[arg(default_value_t = false)]