Advertisement
IslandPenguin

Cli.rs

Mar 25th, 2021
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.74 KB | None | 0 0
  1. use std::path::PathBuf;
  2. use structopt::StructOpt;
  3.  
  4. #[derive(Debug, StructOpt)]
  5. pub enum Action {
  6.     /// Write tasks to the to-do list.
  7.     Add {
  8.         /// The task description text.
  9.         #[structopt()]
  10.         text: String,
  11.     },
  12.     /// Remove an entry from the to-do list by position.
  13.     Done {
  14.         #[structopt()]
  15.         position: usize,
  16.     },
  17.     /// List all tasks in the to-do list.
  18.     List,
  19. }
  20.  
  21. #[derive(Debug, StructOpt)]
  22. #[structopt(
  23.     name = "Rust To-Do CLI",
  24.     about = "A command line to-do app written in Rust"
  25. )]
  26. pub struct CommandLineArgs {
  27.     #[structopt(subcommand)]
  28.     pub action: Action,
  29.  
  30.     ///Options
  31.     #[structopt(parse(from_os_str), short, long)]
  32.     pub todo_file: Option<PathBuf>,
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement