summaryrefslogtreecommitdiffstats
path: root/src/cli.rs
blob: 5e49ed7c788d73e86bd69c967ee52af697c85f34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
use structopt::StructOpt;
use std::path::PathBuf;

#[derive(Debug, StructOpt)]
#[structopt(
  author = "",
  name = "khalessi",
  about = "Command line calendar tool.",
  raw(setting = "structopt::clap::AppSettings::VersionlessSubcommands"),
)]
pub struct CommandLine {
  /// verbosity
  #[structopt(short = "v", parse(from_occurrences))]
  pub verbosity: u64,
  #[structopt(subcommand)]
  pub cmd: Command,
}

#[derive(Debug, StructOpt)]
pub enum Command {
  /// Show agenda view
  #[structopt(name = "agenda", author = "")]
  Agenda(Agenda),
  /// Copy event
  #[structopt(name = "copy", author = "")]
  Copy,
  /// Interact with the cursor
  #[structopt(name = "cursor", author = "")]
  Cursor(Cursor),
  /// Delete event
  #[structopt(name = "delete", author = "")]
  Delete,
  /// Edit event
  #[structopt(name = "edit", author = "")]
  Edit,
  /// Get info about the calendar data
  #[structopt(name = "get", author = "")]
  Get(Get),
  /// Rebuild index
  #[structopt(name = "index", author = "")]
  Index(Index),
  /// Select from the sequence
  #[structopt(name = "list", author = "")]
  List(List),
  /// Create new event
  #[structopt(name = "new", author = "")]
  New(New),
  /// Select from the index
  #[structopt(name = "select", author = "")]
  Select(Select),
  /// Interact with the sequence
  #[structopt(name = "seq", author = "")]
  Seq,
  /// Show the raw ical file of an event
  #[structopt(name = "show", author = "")]
  Show,
  /// undo the most recent action
  #[structopt(name = "undo", author = "")]
  Undo,
  /// Unroll a recurring event
  #[structopt(name = "unroll", author = "")]
  Unroll(Unroll),
}

#[derive(Debug, StructOpt)]
pub struct Agenda {
  /// Show agenda view 
  #[structopt(name = "args")]
  pub args: Vec<String>,
}

#[derive(Debug, StructOpt)]
pub struct Cursor {
  /// Move the cursor on the selection. 
  #[structopt(name = "direction", raw(possible_values = "&Direction::variants()"))]
  pub direction: Option<Direction>,
}

arg_enum! {
#[derive(Debug)]
  pub enum Direction {
    next,
    prev,
  }
}

#[derive(Debug, StructOpt)]
pub struct Get {
  /// Show information about this
  #[structopt(name = "query", raw(possible_values = "&GetArgs::variants()"))]
  pub query: GetArgs,
}


arg_enum! {
#[derive(Debug)]
  pub enum GetArgs{
    calendars,
  }
}

#[derive(Debug, StructOpt)]
pub struct Index {
  /// Rebuild index
  #[structopt(short = "r", long = "reindex")]
  pub reindex: bool,
  /// index path
  #[structopt(name = "path", parse(from_os_str))]
  pub path: Option<PathBuf>,
}

#[derive(Debug, StructOpt)]
pub struct List {
  /// the arguments for the selection
  #[structopt(name = "args")]
  pub args: Vec<String>,
}

#[derive(Debug, StructOpt)]
pub struct Select {
  /// the arguments for the selection
  #[structopt(name = "args")]
  pub args: Vec<String>,
}

#[derive(Debug, StructOpt)]
pub struct Unroll {
  /// The file to unroll
  #[structopt(name = "path", parse(from_os_str))]
  pub path: PathBuf,
}

#[derive(Debug, StructOpt)]
pub struct New {
  /// the calendar
  #[structopt(name = "calendar")]
  pub calendar: String,
  /// from
  #[structopt(name = "from")]
  pub from: String,
  /// to
  #[structopt(name = "to")]
  pub to: String,
  /// summary
  #[structopt(name = "summary")]
  pub summary: String,
  /// location
  #[structopt(name = "location")]
  pub location: String,
}