summaryrefslogtreecommitdiff
path: root/src/opt.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/opt.rs')
-rw-r--r--src/opt.rs70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/opt.rs b/src/opt.rs
new file mode 100644
index 0000000..12c3d26
--- /dev/null
+++ b/src/opt.rs
@@ -0,0 +1,70 @@
+//! 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<PathBuf>,
+
+ /// Which directory to use for the journal.
+ #[structopt(short, long, help = "Directory where journal should be stored")]
+ pub dirname: Option<PathBuf>,
+
+ /// 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<String>,
+}
+
+/// 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,
+ },
+
+ /// Invoke editor on journal entry draft.
+ Edit,
+
+ /// Finish a journal entry draft.
+ Finish,
+}