Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use structopt::StructOpt;
- mod cli;
- mod task;
- use cli::{Action::*, CommandLineArgs};
- use task::Task;
- fn main() {
- // Get the command-line arguments.
- let CommandLineArgs {
- action,
- todo_file,
- } = CommandLineArgs::from_args();
- // Unpack the todo file.
- let todo_file = todo_file.expect("Failed to find todo file");
- // Perform the action.
- match action {
- Add { text } => task::add_task(todo_file, Task::new(text)),
- List => task::list_tasks(todo_file),
- Done { position } => task::complete_task(todo_file, position),
- }
- .expect("Failed to perform action")
- println!("Press any key to continue");
- stdin().read_line(&mut String::new()).unwrap();
- }
Add Comment
Please, Sign In to add comment