-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
26 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,35 @@ | ||
use clap::{Parser, Subcommand}; | ||
use std::fmt::Display; | ||
|
||
#[derive(Debug, Clone, Subcommand)] | ||
use clap::{Parser, ValueEnum}; | ||
|
||
#[derive(Debug, Clone, Default, ValueEnum)] | ||
pub enum SubCommand { | ||
/// Initiate the configuration at the default location | ||
InitConfig, | ||
/// <unimplemented> Edit the configuration | ||
Config, | ||
/// Run rofi-obsidian, default behaviour | ||
#[default] | ||
Run, | ||
} | ||
|
||
impl Display for SubCommand { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
let sub = match *self { | ||
SubCommand::Run => "run", | ||
SubCommand::Config => "config", | ||
SubCommand::InitConfig => "init-config", | ||
}; | ||
|
||
write!(f, "{}", sub) | ||
} | ||
} | ||
|
||
#[derive(Parser, Debug)] | ||
#[command(author, version, about)] | ||
pub struct Args { | ||
#[command(subcommand)] | ||
pub sub: Option<SubCommand>, | ||
#[clap(long, short, default_value_t = SubCommand::default())] | ||
pub command: SubCommand, | ||
#[clap()] | ||
pub selection: Option<String>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters