@@ -33,7 +33,7 @@ fn print_completions<G: Generator>(gen: G, cmd: &mut Command) {
33
33
enum Commands {
34
34
#[ command(
35
35
alias = "e" ,
36
- about = format!( "Edit `{cd}` or `{ts}`, default edit `{cd}` {alias}" ,
36
+ about = format!( "Edit `{cd}` or `{ts}`, {alias}" ,
37
37
cd = "code" . bold( ) ,
38
38
ts = "test cases" . bold( ) ,
39
39
alias = "[ alias: e ]" . bold( )
@@ -51,11 +51,11 @@ enum Commands {
51
51
#[ command( alias = "S" , about = format!( "Syncanhronize leetcode info {}" , "[ alias: S ]" . bold( ) ) ) ]
52
52
Sync ( Force ) ,
53
53
#[ command( alias = "t" , about = format!( "Test your code {}" , "[ alias: t ]" . bold( ) ) ) ]
54
- Test ( SubTestArgs ) ,
54
+ Test ( IdArg ) ,
55
55
#[ command( alias = "st" , about = format!( "Submit your code {}" , "[ alias: st ]" . bold( ) ) ) ]
56
- Submit ( SubTestArgs ) ,
56
+ Submit ( IdArg ) ,
57
57
#[ command( alias = "sl" , about = format!( "Get submit list {}" , "[ alias: sl ]" . bold( ) ) ) ]
58
- Sublist ( SubTestArgs ) ,
58
+ Sublist ( IdArg ) ,
59
59
#[ command( alias = "g" , about = format!( "Generate a config {}" , "[ alias: g ]" . bold( ) ) ) ]
60
60
Gencon ( GenArgs ) ,
61
61
#[ command( alias = "T" , about = format!( "Open Tui {}" , "[ alias: T ]" . bold( ) ) ) ]
@@ -72,14 +72,15 @@ enum Commands {
72
72
#[ derive( Args ) ]
73
73
#[ command( args_conflicts_with_subcommands = true ) ]
74
74
struct GenArgs {
75
- #[ arg( short, long) ]
75
+ #[ arg( short, long, help = "Generate cn config" ) ]
76
76
cn : bool ,
77
77
}
78
78
79
79
#[ derive( Debug ) ]
80
80
#[ derive( Args ) ]
81
81
#[ command( args_conflicts_with_subcommands = true ) ]
82
- struct SubTestArgs {
82
+ struct IdArg {
83
+ #[ arg( help = "Question id" ) ]
83
84
id : u32 ,
84
85
}
85
86
@@ -94,7 +95,7 @@ struct InterArgs {
94
95
#[ derive( Debug ) ]
95
96
#[ derive( Subcommand ) ]
96
97
enum DetailOrEdit {
97
- #[ command( about = "View detail" ) ]
98
+ #[ command( about = "View detail(default) " ) ]
98
99
Detail ( DetailArgsFzy ) ,
99
100
#[ command( about = "Edit code" ) ]
100
101
Edit ,
@@ -111,7 +112,7 @@ struct DetailArgsFzy {
111
112
#[ derive( Args ) ]
112
113
#[ command( args_conflicts_with_subcommands = true ) ]
113
114
struct DetailArgs {
114
- #[ arg( help = "Force update question's information " ) ]
115
+ #[ arg( help = "Question id " ) ]
115
116
id : u32 ,
116
117
#[ arg( short, long, help = "Force update question's information" ) ]
117
118
force : bool ,
@@ -132,25 +133,17 @@ struct EditArgs {
132
133
#[ command( subcommand) ]
133
134
command : Option < CoT > ,
134
135
135
- #[ command( flatten, help = "Id of the be edited question, default edit it " ) ]
136
- id : Option < EditCodeArgs > ,
136
+ #[ command( flatten, help = "Id of the be edited question" ) ]
137
+ id : Option < IdArg > ,
137
138
}
138
139
139
140
#[ derive( Debug ) ]
140
141
#[ derive( Subcommand ) ]
141
142
enum CoT {
142
143
#[ command( about = "Edit code(default)" ) ]
143
- Code ( EditCodeArgs ) ,
144
+ Code ( IdArg ) ,
144
145
#[ command( about = "Edit test case" ) ]
145
- Test ( EditCodeArgs ) ,
146
- }
147
-
148
- #[ derive( Debug ) ]
149
- #[ derive( Args ) ]
150
- #[ command( args_conflicts_with_subcommands = true ) ]
151
- struct EditCodeArgs {
152
- #[ arg( help = "Question id" ) ]
153
- input : u32 ,
146
+ Test ( IdArg ) ,
154
147
}
155
148
156
149
/// Cli runner
@@ -211,11 +204,11 @@ pub async fn run() -> Result<()> {
211
204
} ,
212
205
Commands :: Edit ( args) => match args. command {
213
206
Some ( cmd) => match cmd {
214
- CoT :: Code ( id) => Editor :: open ( IdSlug :: Id ( id. input ) , CodeTestFile :: Code ) . await ?,
215
- CoT :: Test ( id) => Editor :: open ( IdSlug :: Id ( id. input ) , CodeTestFile :: Test ) . await ?,
207
+ CoT :: Code ( id) => Editor :: open ( IdSlug :: Id ( id. id ) , CodeTestFile :: Code ) . await ?,
208
+ CoT :: Test ( id) => Editor :: open ( IdSlug :: Id ( id. id ) , CodeTestFile :: Test ) . await ?,
216
209
} ,
217
210
None => match args. id {
218
- Some ( id) => Editor :: open ( IdSlug :: Id ( id. input ) , CodeTestFile :: Code ) . await ?,
211
+ Some ( id) => Editor :: open ( IdSlug :: Id ( id. id ) , CodeTestFile :: Code ) . await ?,
219
212
None => println ! ( "please give info" ) ,
220
213
} ,
221
214
} ,
0 commit comments