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