summaryrefslogtreecommitdiffstats
path: root/src/cli.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli.rs')
-rw-r--r--src/cli.rs34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/cli.rs b/src/cli.rs
index cc16d1c..948df5f 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -46,28 +46,30 @@ pub struct Agenda {
#[derive(Debug, StructOpt)]
pub struct Cursor {
- /// Move the cursor on the selection. Uses "next" and "prev".
- #[structopt(name = "direction")]
+ /// Move the cursor on the selection.
+ #[structopt(name = "direction", raw(possible_values = "&Direction::variants()"))]
pub direction: Option<Direction>,
}
-#[derive(Debug, StructOpt)]
-pub enum Direction {
- Next,
- Prev,
-}
-
-impl std::str::FromStr for Direction{
- type Err = String;
- fn from_str(s: &str) -> Result<Self, <Self as std::str::FromStr>::Err> {
- match s {
- "prev" => Ok(Direction::Prev),
- "next" => Ok(Direction::Next),
- &_ => Err("Expected 'prev' or 'next'".to_string())
- }
+arg_enum! {
+#[derive(Debug)]
+ pub enum Direction {
+ next,
+ prev,
}
}
+//impl std::str::FromStr for Direction{
+// type Err = String;
+// fn from_str(s: &str) -> Result<Self, <Self as std::str::FromStr>::Err> {
+// match s {
+// "prev" => Ok(Direction::Prev),
+// "next" => Ok(Direction::Next),
+// &_ => Err("Expected 'prev' or 'next'".to_string())
+// }
+// }
+//}
+
#[derive(Debug, StructOpt)]
pub struct Index {
/// Rebuild index