Advertisement
IslandPenguin

main.rs

Mar 24th, 2021
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.63 KB | None | 0 0
  1. use structopt::StructOpt;
  2. mod cli;
  3. mod tasks;
  4.  
  5. use cli::{Action::*, CommandLineArgs};
  6. use tasks::Task;
  7.  
  8. fn main() {
  9.     // Get the command-line arguments.
  10.     let CommandLineArgs { action, todo_file } = CommandLineArgs::from_args();
  11.  
  12.     // Unpack the journal file.
  13.     let journal_file = todo_file.expect("Failed to find journal file");
  14.  
  15.     // Perform the action.
  16.     match action {
  17.         Add { text } => tasks::add_task(todo_file, Task::new(text)),
  18.         List => tasks::list_tasks(todo_file),
  19.         Done { position } => tasks::complete_task(todo_file, position),
  20.     }
  21.     .expect("Failed to perform action")
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement