@@ -60,64 +60,70 @@ pub struct Opt {
6060 pub cmd : Option < Cmd > ,
6161}
6262
63+ #[ derive( Parser , Debug ) ]
64+ pub struct CreateCmd {
65+ #[ arg( verbatim_doc_comment) ]
66+ /// Set post title
67+ /// Example: cnb post create --title 'Title' --body 'Body'
68+ #[ arg( long) ]
69+ #[ arg( value_name = "TITLE" ) ]
70+ pub title : String ,
71+
72+ #[ arg( verbatim_doc_comment) ]
73+ /// Set post body
74+ /// Example: cnb post create --title 'Title' --body 'Body'
75+ #[ arg( long) ]
76+ #[ arg( value_name = "BODY" ) ]
77+ pub body : String ,
78+
79+ #[ arg( verbatim_doc_comment) ]
80+ /// Set post status to publish
81+ /// Example: cnb post create --title 'Title' --body 'Body' --publish
82+ /// *
83+ #[ arg( long) ]
84+ #[ arg( visible_alias = "pub" ) ]
85+ pub publish : bool ,
86+ }
87+
88+ #[ derive( Parser , Debug ) ]
89+ pub struct UpdateCmd {
90+ #[ arg( verbatim_doc_comment) ]
91+ /// Set post title
92+ /// Example: cnb --id 114514 post update --title 'Title'
93+ #[ arg( long) ]
94+ #[ arg( value_name = "TITLE" ) ]
95+ pub title : Option < String > ,
96+
97+ #[ arg( verbatim_doc_comment) ]
98+ /// Set post body
99+ /// Example: cnb --id 114514 post update --body 'Body'
100+ #[ arg( long) ]
101+ #[ arg( value_name = "BODY" ) ]
102+ pub body : Option < String > ,
103+
104+ #[ arg( verbatim_doc_comment) ]
105+ /// Set post publish state
106+ /// Example: cnb --id 114514 post update --publish true
107+ /// *
108+ #[ arg( long) ]
109+ #[ arg( value_name = "BOOL" ) ]
110+ #[ arg( visible_alias = "pub" ) ]
111+ pub publish : Option < bool > ,
112+ }
113+
63114#[ derive( Debug , Subcommand ) ]
64115pub enum Cmd {
65116 #[ clap( verbatim_doc_comment) ]
66117 /// Create post
67118 /// Example: cnb post create --title 'Title' --body 'Body'
68119 /// *
69120 #[ clap( visible_alias = "c" ) ]
70- Create {
71- #[ arg( verbatim_doc_comment) ]
72- /// Set post title
73- /// Example: cnb post create --title 'Title' --body 'Body'
74- #[ arg( long) ]
75- #[ arg( value_name = "TITLE" ) ]
76- title : String ,
77-
78- #[ arg( verbatim_doc_comment) ]
79- /// Set post body
80- /// Example: cnb post create --title 'Title' --body 'Body'
81- #[ arg( long) ]
82- #[ arg( value_name = "BODY" ) ]
83- body : String ,
84-
85- #[ arg( verbatim_doc_comment) ]
86- /// Set post status to publish
87- /// Example: cnb post create --title 'Title' --body 'Body' --publish
88- /// *
89- #[ arg( long) ]
90- #[ arg( visible_alias = "pub" ) ]
91- publish : bool ,
92- } ,
121+ Create ( CreateCmd ) ,
93122 #[ clap( verbatim_doc_comment) ]
94123 /// Update post
95124 /// Example: cnb --id 114514 post update --title 'Title'
96125 /// You should also specify the id of the post via --id
97126 /// *
98127 #[ clap( visible_alias = "u" ) ]
99- Update {
100- #[ arg( verbatim_doc_comment) ]
101- /// Set post title
102- /// Example: cnb --id 114514 post update --title 'Title'
103- #[ arg( long) ]
104- #[ arg( value_name = "TITLE" ) ]
105- title : Option < String > ,
106-
107- #[ arg( verbatim_doc_comment) ]
108- /// Set post body
109- /// Example: cnb --id 114514 post update --body 'Body'
110- #[ arg( long) ]
111- #[ arg( value_name = "BODY" ) ]
112- body : Option < String > ,
113-
114- #[ arg( verbatim_doc_comment) ]
115- /// Set post publish state
116- /// Example: cnb --id 114514 post update --publish true
117- /// *
118- #[ arg( long) ]
119- #[ arg( value_name = "BOOL" ) ]
120- #[ arg( visible_alias = "pub" ) ]
121- publish : Option < bool > ,
122- } ,
128+ Update ( UpdateCmd ) ,
123129}
0 commit comments