Skip to content

Commit b5a991d

Browse files
committed
docs(help): more readable
1 parent a598542 commit b5a991d

File tree

4 files changed

+55
-42
lines changed

4 files changed

+55
-42
lines changed

src/args/cmd/news.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use clap::Parser;
44
pub struct Opt {
55
#[arg(verbatim_doc_comment)]
66
/// Show news list, order by time in DESC
7-
/// Example: cnb news --list
7+
/// Example: cnb news --list
88
#[arg(long)]
99
#[arg(short = 'l')]
1010
pub list: bool,

src/args/cmd/post.rs

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,44 @@ use clap::{Parser, Subcommand};
22

33
#[derive(Parser, Debug)]
44
pub struct Opt {
5-
#[arg(verbatim_doc_comment)]
5+
#[clap(verbatim_doc_comment)]
66
/// Show title and content of a specific post
7-
/// Example: cnb --id 114514 post --show
8-
/// You should also specify the id of the post via --id
7+
/// Example: cnb --id 114514 post --show
8+
/// You should also specify the id of the post via --id
99
#[arg(long)]
1010
#[arg(short = 's')]
1111
pub show: bool,
1212

1313
#[arg(verbatim_doc_comment)]
1414
/// Show metadata of a specific post
15-
/// Example: cnb --id 114514 post --show-meta
16-
/// You should also specify the id of the post via --id
15+
/// Example: cnb --id 114514 post --show-meta
16+
/// You should also specify the id of the post via --id
1717
#[arg(long)]
1818
#[arg(short = 'm')]
1919
pub show_meta: bool,
2020

2121
#[arg(verbatim_doc_comment)]
2222
/// Show post list, order by time in DESC
23-
/// Example: cnb post --list
24-
/// <LENGTH> should in range [0,100]
25-
/// If <LENGTH> greater than 100, it will be set to 100
23+
/// Example: cnb post --list
24+
/// <LENGTH> should in range [0,100]
25+
/// If <LENGTH> greater than 100, it will be set to 100
2626
#[arg(long)]
2727
#[arg(short = 'l')]
2828
pub list: bool,
2929

3030
#[arg(verbatim_doc_comment)]
3131
/// Delete post
32-
/// Example: cnb --id 114514 post --delete
33-
/// You should also specify the id of the post via --id
32+
/// Example: cnb --id 114514 post --delete
33+
/// You should also specify the id of the post via --id
34+
/// *
3435
#[arg(long)]
3536
#[arg(visible_alias = "del")]
3637
pub delete: bool,
3738

3839
#[arg(verbatim_doc_comment)]
3940
/// Search post by keyword and output the post id list that matches
40-
/// Example: cnb post --search 'Hello world'
41+
/// Example: cnb post --search 'Hello world'
42+
/// *
4143
#[arg(long)]
4244
#[arg(short = 'f')]
4345
#[arg(visible_alias = "find")]
@@ -50,53 +52,59 @@ pub struct Opt {
5052

5153
#[derive(Debug, Subcommand)]
5254
pub enum Cmd {
55+
#[clap(verbatim_doc_comment)]
5356
/// Create post
5457
/// Example: cnb post create --title 'Title' --body 'Body'
58+
/// *
5559
#[clap(visible_alias = "c")]
5660
Create {
5761
#[arg(verbatim_doc_comment)]
5862
/// Set post title
59-
/// Example: cnb post create --title 'Title' --body 'Body'
63+
/// Example: cnb post create --title 'Title' --body 'Body'
6064
#[arg(long)]
6165
#[arg(value_name = "TITLE")]
6266
title: String,
6367

6468
#[arg(verbatim_doc_comment)]
6569
/// Set post body
66-
/// Example: cnb post create --title 'Title' --body 'Body'
70+
/// Example: cnb post create --title 'Title' --body 'Body'
6771
#[arg(long)]
6872
#[arg(value_name = "BODY")]
6973
body: String,
7074

7175
#[arg(verbatim_doc_comment)]
7276
/// Set post status to publish
73-
/// Example: cnb post create --title 'Title' --body 'Body' --publish
77+
/// Example: cnb post create --title 'Title' --body 'Body' --publish
78+
/// *
7479
#[arg(long)]
7580
#[arg(visible_alias = "pub")]
7681
publish: bool,
7782
},
83+
#[clap(verbatim_doc_comment)]
7884
/// Update post
7985
/// Example: cnb --id 114514 post update --title 'Title'
80-
/// You should also specify the id of the post via --id
86+
/// You should also specify the id of the post via --id
87+
/// *
8188
#[clap(visible_alias = "u")]
8289
Update {
8390
#[arg(verbatim_doc_comment)]
8491
/// Set post title
85-
/// Example: cnb --id 114514 post update --title 'Title'
92+
/// Example: cnb --id 114514 post update --title 'Title'
8693
#[arg(long)]
8794
#[arg(value_name = "TITLE")]
8895
title: Option<String>,
8996

9097
#[arg(verbatim_doc_comment)]
9198
/// Set post body
92-
/// Example: cnb --id 114514 post update --body 'Body'
99+
/// Example: cnb --id 114514 post update --body 'Body'
93100
#[arg(long)]
94101
#[arg(value_name = "BODY")]
95102
body: Option<String>,
96103

97104
#[arg(verbatim_doc_comment)]
98105
/// Set post publish state
99-
/// Example: cnb --id 114514 post update --publish true
106+
/// Example: cnb --id 114514 post update --publish true
107+
/// *
100108
#[arg(long)]
101109
#[arg(value_name = "BOOL")]
102110
#[arg(visible_alias = "pub")]

src/args/cmd/user.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ use clap::Parser;
44
pub struct Opt {
55
#[arg(verbatim_doc_comment)]
66
/// Login with your personal access token (PAT)
7-
/// Example: cnb user --login 'FOOBARBAZ'
8-
/// PAT will be saved in ~/.cnbrc
9-
/// You can create PAT in https://account.cnblogs.com/tokens
7+
/// Example: cnb user --login 'FOOBARBAZ'
8+
/// PAT will be saved in ~/.cnbrc
9+
/// You can create PAT in https://account.cnblogs.com/tokens
1010
#[arg(long)]
1111
#[arg(value_name = "PAT")]
1212
pub login: Option<String>,
1313

1414
#[arg(verbatim_doc_comment)]
1515
/// Logout and remove ~/.cnbrc
16-
/// Example: cnb user --logout
16+
/// Example: cnb user --logout
1717
#[arg(long)]
1818
pub logout: bool,
1919

2020
#[arg(verbatim_doc_comment)]
2121
/// Show user info
22-
/// Example: cnb user --info
22+
/// Example: cnb user --info
2323
#[arg(long)]
2424
#[arg(short = 'i')]
2525
pub info: bool,

src/args/mod.rs

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,58 +19,61 @@ pub struct Args {
1919

2020
#[arg(verbatim_doc_comment)]
2121
/// Provide ID required by other options
22-
/// Example: cnb --id 114514 post --show
22+
/// Example: cnb --id 114514 post --show
2323
#[arg(long)]
2424
pub id: Option<usize>,
2525

2626
#[arg(verbatim_doc_comment)]
2727
/// Reverse list output
28-
/// Example: cnb --rev ing --list
28+
/// Example: cnb --rev ing --list
2929
#[arg(long)]
3030
pub rev: bool,
3131

3232
#[arg(verbatim_doc_comment)]
3333
/// Skip items while request list
34-
/// Example: cnb --skip 2 ing --list
35-
/// Use this option to save network I/O if some items of the list output are not needed
36-
/// If this option is required but not specified, it will be set to 0
34+
/// Example: cnb --skip 2 ing --list
35+
/// Use this option to save network I/O if some items of the list output are not needed
36+
/// If this option is required but not specified, it will be set to 0
3737
#[arg(long)]
3838
#[arg(short = 's')]
3939
#[arg(value_name = "LENGTH")]
4040
pub skip: Option<usize>,
4141

4242
#[arg(verbatim_doc_comment)]
4343
/// Take items while request list
44-
/// Example: cnb --take 2 ing --list
45-
/// Use this option to save network I/O if only a subset of the list output are required
46-
/// <LENGTH> should be in the range [0,100]
47-
/// If <LENGTH> is greater than 100, it will be set to 100
48-
/// If this option is required but not specified, it will be set to 8
44+
/// Example: cnb --take 2 ing --list
45+
/// Use this option to save network I/O if only a subset of the list output are required
46+
/// <LENGTH> should be in the range [0,100]
47+
/// If <LENGTH> is greater than 100, it will be set to 100
48+
/// If this option is required but not specified, it will be set to 8
4949
#[arg(long)]
5050
#[arg(short = 't')]
5151
#[arg(value_name = "LENGTH")]
5252
pub take: Option<usize>,
5353

5454
#[arg(verbatim_doc_comment)]
5555
/// Execute with specific PAT
56-
/// Example: cnb --with-pat 'FOOBARBAZ' post --list
57-
/// Your PAT in ~/.cnbrc will be ignored in this execution if it exists
58-
/// Please login if you don't want to input PAT everytime, try 'cnb user --help' for more details
56+
/// Example: cnb --with-pat 'FOOBARBAZ' post --list
57+
/// Your PAT in ~/.cnbrc will be ignored in this execution if it exists
58+
/// Please login if you don't want to input PAT everytime, try 'cnb user --help' for more details
5959
#[arg(long)]
6060
#[arg(value_name = "PAT")]
6161
pub with_pat: Option<String>,
6262

6363
#[arg(verbatim_doc_comment)]
6464
/// Execute in debug mode, this will print some messages for the developer
65-
/// Example: cnb --debug ing --list
66-
/// THIS OPTION IS UNSTABLE FOREVER and any output from it may change in the future
67-
/// You should NEVER rely on the output while you turn this option on
65+
/// Example: cnb --debug ing --list
66+
/// THIS OPTION IS UNSTABLE FOREVER and any output from it may change in the future
67+
/// You should NEVER rely on the output while you turn this option on
68+
/// *
6869
#[arg(long)]
6970
#[clap(visible_alias = "dbg")]
7071
pub debug: bool,
7172

7273
#[arg(verbatim_doc_comment)]
7374
/// Configure the output style
75+
/// Example: cnb --style json ing list
76+
/// *
7477
#[arg(long)]
7578
#[arg(value_enum)]
7679
#[arg(hide_possible_values = true)]
@@ -80,15 +83,17 @@ pub struct Args {
8083

8184
#[arg(verbatim_doc_comment)]
8285
/// Fail if error occurred
83-
/// Example: cnb --fail-on-error ing --list
86+
/// Example: cnb --fail-on-error ing --list
87+
/// *
8488
#[arg(long)]
8589
#[clap(visible_alias = "foe")]
8690
#[arg(default_value_t = false)]
8791
pub fail_on_error: bool,
8892

8993
#[arg(verbatim_doc_comment)]
9094
/// Suppress all output
91-
/// Example: cnb --quiet ing --list
95+
/// Example: cnb --quiet ing --list
96+
/// *
9297
#[arg(long)]
9398
#[clap(visible_alias = "silent")]
9499
#[arg(default_value_t = false)]

0 commit comments

Comments
 (0)