@@ -127,28 +127,31 @@ pub fn setup(src_path: &Path, profile: Profile) {
127
127
128
128
// Used to get the path for `Subcommand::Setup`
129
129
pub fn interactive_path ( ) -> io:: Result < Profile > {
130
- fn abbrev_all ( ) -> impl Iterator < Item = ( String , Profile ) > {
131
- ( 'a' ..) . map ( |c| c. to_string ( ) ) . zip ( Profile :: all ( ) )
130
+ fn abbrev_all ( ) -> impl Iterator < Item = ( ( String , String ) , Profile ) > {
131
+ ( 'a' ..)
132
+ . zip ( 1 ..)
133
+ . map ( |( letter, number) | ( letter. to_string ( ) , number. to_string ( ) ) )
134
+ . zip ( Profile :: all ( ) )
132
135
}
133
136
134
137
fn parse_with_abbrev ( input : & str ) -> Result < Profile , String > {
135
138
let input = input. trim ( ) . to_lowercase ( ) ;
136
- for ( letter, profile) in abbrev_all ( ) {
137
- if input == letter {
139
+ for ( ( letter, number ) , profile) in abbrev_all ( ) {
140
+ if input == letter || input == number {
138
141
return Ok ( profile) ;
139
142
}
140
143
}
141
144
input. parse ( )
142
145
}
143
146
144
147
println ! ( "Welcome to the Rust project! What do you want to do with x.py?" ) ;
145
- for ( letter, profile) in abbrev_all ( ) {
148
+ for ( ( letter, _ ) , profile) in abbrev_all ( ) {
146
149
println ! ( "{}) {}: {}" , letter, profile, profile. purpose( ) ) ;
147
150
}
148
151
let template = loop {
149
152
print ! (
150
153
"Please choose one ({}): " ,
151
- abbrev_all( ) . map( |( l , _) | l) . collect:: <Vec <_>>( ) . join( "/" )
154
+ abbrev_all( ) . map( |( ( l , _ ) , _) | l) . collect:: <Vec <_>>( ) . join( "/" )
152
155
) ;
153
156
io:: stdout ( ) . flush ( ) ?;
154
157
let mut input = String :: new ( ) ;
0 commit comments