Minor refactoring.
This commit is contained in:
parent
2b0374d45b
commit
8e77725334
3 changed files with 35 additions and 40 deletions
|
@ -114,7 +114,7 @@ impl Cradle {
|
|||
|
||||
// Parse command line argument to --command into a vector of strings suitable
|
||||
// for process::Command::new().
|
||||
pub fn parse(input: &str) -> Vec<String> {
|
||||
pub fn parse(input: String) -> Vec<String> {
|
||||
let mut command: Vec<String> = Vec::new();
|
||||
let mut segment: String = String::new();
|
||||
let mut quoted = false;
|
||||
|
|
10
src/lib.rs
10
src/lib.rs
|
@ -17,6 +17,7 @@
|
|||
|
||||
extern crate signal_hook;
|
||||
extern crate termion;
|
||||
extern crate unicode_segmentation;
|
||||
mod alarm;
|
||||
mod buffer;
|
||||
mod clock;
|
||||
|
@ -362,8 +363,7 @@ impl Config {
|
|||
};
|
||||
let mut iter = args.skip(1);
|
||||
|
||||
loop {
|
||||
if let Some(arg) = iter.next() {
|
||||
while let Some(arg) = iter.next() {
|
||||
match arg.as_str() {
|
||||
"-h" | "--help" => {
|
||||
// Print usage information and exit
|
||||
|
@ -382,8 +382,7 @@ impl Config {
|
|||
"-q" | "--quit" => config.quit = true,
|
||||
"-e" | "--exec" => {
|
||||
if let Some(cmd) = iter.next() {
|
||||
//config.command = Some(Config::parse_to_command(&e));
|
||||
config.commands.add(Cradle::parse(&cmd));
|
||||
config.commands.add(Cradle::parse(cmd));
|
||||
} else {
|
||||
return Err(format!("Missing parameter to \"{}\".", arg));
|
||||
}
|
||||
|
@ -399,9 +398,6 @@ impl Config {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
} // All command line parameters processed.
|
||||
}
|
||||
Ok(config)
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with Kitchentimer. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
extern crate unicode_segmentation;
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
||||
pub fn grapheme_truncate(input: &mut String, limit: usize, ellipse: char) {
|
||||
|
|
Loading…
Reference in a new issue