-
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
4 changed files
with
45 additions
and
28 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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