@@ -34,6 +34,7 @@ pub struct CommandDefinition {
3434 flags_func : fn ( ) -> Vec < Flag > ,
3535 func : CommandFunc ,
3636 synopsis : Option < String > ,
37+ enable_cas : bool ,
3738}
3839
3940impl CommandDefinition {
@@ -43,13 +44,15 @@ impl CommandDefinition {
4344 flags_func : fn ( ) -> Vec < Flag > ,
4445 func : CommandFunc ,
4546 synopsis : Option < impl ToString > ,
47+ enable_cas : bool ,
4648 ) -> Self {
4749 CommandDefinition {
4850 aliases : aliases. to_string ( ) ,
4951 doc : doc. to_string ( ) ,
5052 flags_func,
5153 func,
5254 synopsis : synopsis. map ( |s| s. to_string ( ) ) ,
55+ enable_cas,
5356 }
5457 }
5558
@@ -78,6 +81,10 @@ impl CommandDefinition {
7881 . split ( '|' )
7982 . find_map ( |a| a. strip_prefix ( "legacy:" ) )
8083 }
84+
85+ pub fn enable_cas ( & self ) -> bool {
86+ self . enable_cas
87+ }
8188}
8289
8390#[ derive( Default ) ]
@@ -129,7 +136,14 @@ impl Deref for CommandTable {
129136}
130137
131138pub trait Register < FN , T > {
132- fn register ( & mut self , f : FN , aliases : & str , doc : & str , synopsis : Option < & str > ) ;
139+ fn register (
140+ & mut self ,
141+ f : FN ,
142+ aliases : & str ,
143+ doc : & str ,
144+ synopsis : Option < & str > ,
145+ enable_cas : bool ,
146+ ) ;
133147}
134148
135149// OptionalRepo commands.
@@ -138,7 +152,14 @@ where
138152 S : TryFrom < ParseOutput , Error = anyhow:: Error > + StructFlags ,
139153 FN : Fn ( ReqCtx < S > , Option < & Repo > ) -> Result < u8 > + ' static ,
140154{
141- fn register ( & mut self , f : FN , aliases : & str , doc : & str , synopsis : Option < & str > ) {
155+ fn register (
156+ & mut self ,
157+ f : FN ,
158+ aliases : & str ,
159+ doc : & str ,
160+ synopsis : Option < & str > ,
161+ enable_cas : bool ,
162+ ) {
142163 self . insert_aliases ( aliases) ;
143164 let func = move |opts : ParseOutput , io : & IO , repo : & OptionalRepo | {
144165 f (
@@ -147,7 +168,7 @@ where
147168 )
148169 } ;
149170 let func = CommandFunc :: OptionalRepo ( Box :: new ( func) ) ;
150- let def = CommandDefinition :: new ( aliases, doc, S :: flags, func, synopsis) ;
171+ let def = CommandDefinition :: new ( aliases, doc, S :: flags, func, synopsis, enable_cas ) ;
151172 self . commands . insert ( aliases. to_string ( ) , def) ;
152173 }
153174}
@@ -158,13 +179,20 @@ where
158179 S : TryFrom < ParseOutput , Error = anyhow:: Error > + StructFlags ,
159180 FN : Fn ( ReqCtx < S > , & Repo ) -> Result < u8 > + ' static ,
160181{
161- fn register ( & mut self , f : FN , aliases : & str , doc : & str , synopsis : Option < & str > ) {
182+ fn register (
183+ & mut self ,
184+ f : FN ,
185+ aliases : & str ,
186+ doc : & str ,
187+ synopsis : Option < & str > ,
188+ enable_cas : bool ,
189+ ) {
162190 self . insert_aliases ( aliases) ;
163191 let func = move |opts : ParseOutput , io : & IO , repo : & Repo | {
164192 f ( ReqCtx :: new ( repo. config ( ) . clone ( ) , opts, io. clone ( ) ) ?, repo)
165193 } ;
166194 let func = CommandFunc :: Repo ( Box :: new ( func) ) ;
167- let def = CommandDefinition :: new ( aliases, doc, S :: flags, func, synopsis) ;
195+ let def = CommandDefinition :: new ( aliases, doc, S :: flags, func, synopsis, enable_cas ) ;
168196 self . commands . insert ( aliases. to_string ( ) , def) ;
169197 }
170198}
@@ -175,13 +203,20 @@ where
175203 S : TryFrom < ParseOutput , Error = anyhow:: Error > + StructFlags ,
176204 FN : Fn ( ReqCtx < S > ) -> Result < u8 > + ' static ,
177205{
178- fn register ( & mut self , f : FN , aliases : & str , doc : & str , synopsis : Option < & str > ) {
206+ fn register (
207+ & mut self ,
208+ f : FN ,
209+ aliases : & str ,
210+ doc : & str ,
211+ synopsis : Option < & str > ,
212+ enable_cas : bool ,
213+ ) {
179214 self . insert_aliases ( aliases) ;
180215 let func = move |opts : ParseOutput , io : & IO , config : & Arc < dyn Config > | {
181216 f ( ReqCtx :: new ( config. clone ( ) , opts, io. clone ( ) ) ?)
182217 } ;
183218 let func = CommandFunc :: NoRepo ( Box :: new ( func) ) ;
184- let def = CommandDefinition :: new ( aliases, doc, S :: flags, func, synopsis) ;
219+ let def = CommandDefinition :: new ( aliases, doc, S :: flags, func, synopsis, enable_cas ) ;
185220 self . commands . insert ( aliases. to_string ( ) , def) ;
186221 }
187222}
@@ -192,7 +227,14 @@ where
192227 S : TryFrom < ParseOutput , Error = anyhow:: Error > + StructFlags ,
193228 FN : Fn ( ReqCtx < S > , & Repo , & WorkingCopy ) -> Result < u8 > + ' static ,
194229{
195- fn register ( & mut self , f : FN , aliases : & str , doc : & str , synopsis : Option < & str > ) {
230+ fn register (
231+ & mut self ,
232+ f : FN ,
233+ aliases : & str ,
234+ doc : & str ,
235+ synopsis : Option < & str > ,
236+ enable_cas : bool ,
237+ ) {
196238 self . insert_aliases ( aliases) ;
197239 let func = move |opts : ParseOutput , io : & IO , repo : & Repo , working_copy : & WorkingCopy | {
198240 f (
@@ -202,7 +244,7 @@ where
202244 )
203245 } ;
204246 let func = CommandFunc :: WorkingCopy ( Box :: new ( func) ) ;
205- let def = CommandDefinition :: new ( aliases, doc, S :: flags, func, synopsis) ;
247+ let def = CommandDefinition :: new ( aliases, doc, S :: flags, func, synopsis, enable_cas ) ;
206248 self . commands . insert ( aliases. to_string ( ) , def) ;
207249 }
208250}
0 commit comments