Commit e99674b245
Unregistered key
Layout: unified · split
src/config.rs +28 −6
| @@ -5,7 +5,7 @@ use std::collections::HashMap; | |||
| 5 | use std::fmt; | 5 | use std::fmt; |
| 6 | use std::fs::File; | 6 | use std::fs::File; |
| 7 | use std::hash::{Hash, Hasher}; | 7 | use std::hash::{Hash, Hasher}; |
| 8 | use std::io::{BufReader, BufWriter}; | 8 | use std::io::{BufReader, BufWriter, Write}; |
| 9 | use std::path::{Path, PathBuf}; | 9 | use std::path::{Path, PathBuf}; |
| 10 | use std::process; | 10 | use std::process; |
| 11 | 11 | ||
| @@ -874,11 +874,33 @@ impl ApplicationSettings { | |||
| 874 | } else if profiles.len() == 1 { | 874 | } else if profiles.len() == 1 { |
| 875 | profiles.into_iter().next().unwrap() | 875 | profiles.into_iter().next().unwrap() |
| 876 | } else { | 876 | } else { |
| 877 | usage!( | 877 | loop { |
| 878 | "No profile specified. \ | 878 | println!("\nNo profile specified. Available profiles:"); |
| 879 | Please use -P or add \"default_profile\" to your configuration.\n\n\ | 879 | profiles |
| 880 | For more information try '--help'", | 880 | .keys() |
| 881 | ); | 881 | .enumerate() |
| 882 | .for_each(|(i, name)| println!("{}: {}", i, name)); | ||
| 883 | |||
| 884 | print!("Select a number or 'q' to quit: "); | ||
| 885 | let _ = std::io::stdout().flush(); | ||
| 886 | |||
| 887 | let mut input = String::new(); | ||
| 888 | let _ = std::io::stdin().read_line(&mut input); | ||
| 889 | |||
| 890 | if input.trim() == "q" { | ||
| 891 | usage!( | ||
| 892 | "No profile specified. \ | ||
| 893 | Please use -P or add \"default_profile\" to your configuration.\n\n\ | ||
| 894 | For more information try '--help'", | ||
| 895 | ); | ||
| 896 | } | ||
| 897 | if let Ok(i) = input.trim().parse::<usize>() { | ||
| 898 | if i < profiles.len() { | ||
| 899 | break profiles.into_iter().nth(i).unwrap(); | ||
| 900 | } | ||
| 901 | } | ||
| 902 | println!("\nInvalid index."); | ||
| 903 | } | ||
| 882 | }; | 904 | }; |
| 883 | 905 | ||
| 884 | let macros = merge_maps(macros, profile.macros.take()).unwrap_or_default(); | 906 | let macros = merge_maps(macros, profile.macros.take()).unwrap_or_default(); |