@@ -93,43 +93,40 @@ impl Spec {
9393 let mut args = args. iter ( ) ;
9494
9595 match ( args. next ( ) , args. next ( ) , args. next ( ) ) {
96- ( Some ( maybe_version) , None , None ) => {
97- // The case we are concerned with here is where we have `<number>`.
98- // That is, exactly one argument, which is a valid version specifier.
99- //
100- // - `volta install node@12` is allowed.
101- // - `volta install 12` is an error.
102- // - `volta install lts` is an error.
103- if is_version_like ( maybe_version. as_ref ( ) ) {
104- return Err ( ErrorKind :: InvalidInvocationOfBareVersion {
105- action : action. to_string ( ) ,
106- version : maybe_version. as_ref ( ) . to_string ( ) ,
107- }
108- . into ( ) ) ;
96+ // The case we are concerned with here is where we have `<number>`.
97+ // That is, exactly one argument, which is a valid version specifier.
98+ //
99+ // - `volta install node@12` is allowed.
100+ // - `volta install 12` is an error.
101+ // - `volta install lts` is an error.
102+ ( Some ( maybe_version) , None , None ) if is_version_like ( maybe_version. as_ref ( ) ) => {
103+ Err ( ErrorKind :: InvalidInvocationOfBareVersion {
104+ action : action. to_string ( ) ,
105+ version : maybe_version. as_ref ( ) . to_string ( ) ,
109106 }
107+ . into ( ) )
110108 }
111- ( Some ( name ) , Some ( maybe_version ) , None ) => {
112- // The case we are concerned with here is where we have `<tool> <number>`.
113- // This is only interesting if there are exactly two args. Then we care
114- // whether the two items are a bare name (with no `@version`), followed
115- // by a valid version specifier (ignoring custom tags). That is:
116- //
117- // - `volta install node@lts latest` is allowed .
118- // - `volta install node latest` is an error .
119- // - `volta install node latest yarn` is allowed.
120- if !HAS_VERSION . is_match ( name. as_ref ( ) ) && is_version_like ( maybe_version . as_ref ( ) ) {
121- return Err ( ErrorKind :: InvalidInvocation {
122- action : action . to_string ( ) ,
123- name : name . as_ref ( ) . to_string ( ) ,
124- version : maybe_version . as_ref ( ) . to_string ( ) ,
125- }
126- . into ( ) ) ;
109+ // The case we are concerned with here is where we have `<tool> <number>`.
110+ // This is only interesting if there are exactly two args. Then we care
111+ // whether the two items are a bare name (with no `@version`), followed
112+ // by a valid version specifier (ignoring custom tags). That is:
113+ //
114+ // - `volta install node@lts latest` is allowed.
115+ // - `volta install node latest` is an error .
116+ // - `volta install node latest yarn ` is allowed .
117+ ( Some ( name ) , Some ( maybe_version ) , None )
118+ if !HAS_VERSION . is_match ( name. as_ref ( ) )
119+ && is_version_like ( maybe_version . as_ref ( ) ) =>
120+ {
121+ Err ( ErrorKind :: InvalidInvocation {
122+ action : action . to_string ( ) ,
123+ name : name . as_ref ( ) . to_string ( ) ,
124+ version : maybe_version . as_ref ( ) . to_string ( ) ,
127125 }
126+ . into ( ) )
128127 }
129- _ => { }
128+ _ => Ok ( ( ) ) ,
130129 }
131-
132- Ok ( ( ) )
133130 }
134131
135132 /// Compare `Spec`s for sorting when converting from strings
0 commit comments