@@ -180,6 +180,26 @@ pub enum RegistryCommands {
180180 #[ clap( about = "Show current binary registry and version registry" ) ]
181181 Show ,
182182
183+ #[ clap( name = "official" , about = "Set registry to official registry" ) ]
184+ Official {
185+ #[ clap(
186+ long = "write-local" ,
187+ short = 'L' ,
188+ help = "Write to current directory .dvmrc file instead of global(user-wide) config"
189+ ) ]
190+ write_local : bool ,
191+ } ,
192+
193+ #[ clap( name = "cn" , about = "Set registry to cn registry" ) ]
194+ Cn {
195+ #[ clap(
196+ long = "write-local" ,
197+ short = 'L' ,
198+ help = "Write to current directory .dvmrc file instead of global(user-wide) config"
199+ ) ]
200+ write_local : bool ,
201+ } ,
202+
183203 #[ clap( about = "Set registry to one of predefined registries" ) ]
184204 Set {
185205 predefined : RegistryPredefined ,
@@ -283,3 +303,27 @@ impl RegistryPredefined {
283303 . to_string ( )
284304 }
285305}
306+
307+ #[ cfg( test) ]
308+ mod tests {
309+ use super :: * ;
310+
311+ #[ test]
312+ fn parses_registry_predefined_shortcuts ( ) {
313+ let cli = Cli :: try_parse_from ( [ "dvm" , "registry" , "cn" ] ) . unwrap ( ) ;
314+ match cli. command {
315+ Commands :: Registry {
316+ command : RegistryCommands :: Cn { write_local } ,
317+ } => assert ! ( !write_local) ,
318+ _ => panic ! ( "expected registry cn shortcut" ) ,
319+ }
320+
321+ let cli = Cli :: try_parse_from ( [ "dvm" , "registry" , "official" , "--write-local" ] ) . unwrap ( ) ;
322+ match cli. command {
323+ Commands :: Registry {
324+ command : RegistryCommands :: Official { write_local } ,
325+ } => assert ! ( write_local) ,
326+ _ => panic ! ( "expected registry official shortcut" ) ,
327+ }
328+ }
329+ }
0 commit comments