summaryrefslogtreecommitdiffstats
path: root/src/cli.rs
blob: a7843f4ce7eb249f4050bc4cb971ba60015ecf47 (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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
use std::path::PathBuf;
use structopt::StructOpt;

#[derive(Debug, StructOpt)]
#[structopt(
  author = "",
  name = "khaleesi",
  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(AgendaArgs),
  /// Copy event
  #[structopt(name = "copy", author = "")]
  Copy,
  /// Interact with the cursor
  #[structopt(name = "cursor", author = "")]
  Cursor(CursorArgs),
  /// 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(GetArgs),
  /// Rebuild index
  #[structopt(name = "index", author = "")]
  Index(IndexArgs),
  /// Select from the sequence
  #[structopt(name = "list", author = "")]
  List(ListArgs),
  /// Modify an event
  #[structopt(name = "modify", author = "")]
  Modify(ModifyArgs),
  /// Create new event
  #[structopt(name = "new", author = "")]
  New(NewArgs),
  /// Select from the index
  #[structopt(name = "select", author = "")]
  Select(SelectArgs),
  /// 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(UnrollArgs),
}

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

#[derive(Debug, StructOpt)]
pub struct CursorArgs {
  /// 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 GetArgs {
  /// Show information about this
  #[structopt(name = "query", raw(possible_values = "&GetQueryArgs::variants()"))]
  pub query: GetQueryArgs,
}

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

#[derive(Debug, StructOpt)]
pub struct IndexArgs {
  /// 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 ListArgs {
  /// the arguments for the selection
  #[structopt(name = "args")]
  pub args: Vec<String>,
}

#[derive(Debug, StructOpt)]
pub struct ModifyArgs {
  /// Rebuild index
  #[structopt(short = "n", long = "dry-run")]
  pub dry_run: bool,
  /// index path
  #[structopt(subcommand)]
  pub modify_cmd: ModifyCommand,
}

#[derive(Debug, StructOpt)]
pub enum ModifyCommand {
  /// Show agenda view
  #[structopt(name = "remove-xlicerror", author = "")]
  RemoveXlicerror,
}

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

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

#[derive(Debug, StructOpt)]
pub struct NewArgs {
  /// 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,
}