//! Command line options. use std::path::PathBuf; use structopt::StructOpt; /// A parsed command line. #[derive(Debug, StructOpt)] #[structopt(about = "maintain a journal")] pub struct Opt { /// Global options, common for all subcommands. #[structopt(flatten)] pub global: GlobalOptions, /// The subcommand. #[structopt(subcommand)] pub cmd: SubCommand, } /// Global options. /// /// These options are common to all subcommands. #[derive(Debug, StructOpt)] pub struct GlobalOptions { /// Which configuration file to read. #[structopt(short, long, help = "Configuration file")] pub config: Option, /// Which directory to use for the journal. #[structopt(short, long, help = "Directory where journal should be stored")] pub dirname: Option, /// Sub-directory in journal where new entries are put. #[structopt(long)] pub entries: Option, /// Which editor to invoke for editing journal entry drafts. #[structopt( long, short, help = "Invoke EDITOR for user to edit draft journal entry" )] pub editor: Option, } /// A subcommand. #[derive(Debug, StructOpt)] pub enum SubCommand { /// Show configuration. Config, /// Create a new journal in the chosen directory. Init { #[structopt(help = "Short name for journal")] journalname: String, #[structopt(help = "Short description of journal, its title")] description: String, }, /// Check if a directory is a journal. IsJournal, /// Create draft for a new journal entry. New { #[structopt(help = "Title of new draft")] title: String, #[structopt(long, help = "Add link to a topic page")] topic: Option, }, /// Create topic page. NewTopic { #[structopt(help = "Path to topic page in journal")] path: PathBuf, #[structopt(help = "Title of topic page")] title: String, }, /// Invoke editor on journal entry draft. Edit { /// Draft id. draft: String, }, /// Finish a journal entry draft. Finish { /// Draft id. draft: String, /// Set base name of published file. basename: String, }, }