Skip to content

Commit

Permalink
refactor: put directives below comments for cli arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Anomalocaridid committed Dec 14, 2024
1 parent 11da609 commit 8b3f6f4
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use clap_complete::{
#[clap(disable_help_subcommand = true)]
#[clap(version, about)]
pub enum Cmd {
#[clap(verbatim_doc_comment)]
/// List default apps and the associated handlers
///
/// Output is formatted as a table with two columns.
Expand Down Expand Up @@ -58,12 +57,13 @@ pub enum Cmd {
/// }
///
/// Where each top-level key has an array with the same scheme as the normal `--json` output
#[clap(verbatim_doc_comment)]
List {
#[clap(long)]
/// Output handler info as json
#[clap(long)]
json: bool,
#[clap(long, short)]
/// Expand wildcards in mimetypes and show global defaults
#[clap(long, short)]
all: bool,
},

Expand All @@ -75,8 +75,8 @@ pub enum Cmd {
/// you will be prompted to select one using `selector` from ~/.config/handlr/handlr.toml.
/// Otherwise, the default handler will be opened.
Open {
#[clap(required = true, add=ArgValueCompleter::new(PathCompleter::any()))]
/// Paths/URLs to open
#[clap(required = true, add=ArgValueCompleter::new(PathCompleter::any()))]
paths: Vec<UserPath>,
#[command(flatten)]
selector_args: SelectorArgs,
Expand All @@ -94,11 +94,11 @@ pub enum Cmd {
///
/// Currently does not support regex handlers.
Set {
#[clap(add = ArgValueCompleter::new(autocomplete_mimes))]
/// Mimetype or file extension to operate on.
#[clap(add = ArgValueCompleter::new(autocomplete_mimes))]
mime: MimeOrExtension,
#[clap(add = ArgValueCompleter::new(autocomplete_desktop_files))]
/// Desktop file of handler program
#[clap(add = ArgValueCompleter::new(autocomplete_desktop_files))]
handler: DesktopHandler,
},

Expand All @@ -111,8 +111,8 @@ pub enum Cmd {
///
/// Currently does not support regex handlers.
Unset {
#[clap(add = ArgValueCompleter::new(autocomplete_mimes))]
/// Mimetype or file extension to unset the default handler of
#[clap(add = ArgValueCompleter::new(autocomplete_mimes))]
mime: MimeOrExtension,
},

Expand All @@ -124,18 +124,17 @@ pub enum Cmd {
/// you will be prompted to select one using `selector` from ~/.config/handlr/handlr.toml.
/// Otherwise, the default handler will be opened.
Launch {
#[clap(add = ArgValueCompleter::new(autocomplete_mimes))]
/// Mimetype or file extension to launch the handler of
#[clap(add = ArgValueCompleter::new(autocomplete_mimes))]
mime: MimeOrExtension,
/// Arguments to pass to handler program
// Not necessarily a path, but completing as a path tends to be the expected "default" behavior
#[clap(add=ArgValueCompleter::new(PathCompleter::any()))]
/// Arguments to pass to handler program
args: Vec<String>,
#[command(flatten)]
selector_args: SelectorArgs,
},

#[clap(verbatim_doc_comment)]
/// Get handler for this mime/extension
///
/// If multiple handlers are set and `enable_selector` is set to true,
Expand All @@ -154,12 +153,13 @@ pub enum Cmd {
///
/// Note that when handlr is not being directly output to a terminal, and the handler is a terminal program,
/// the "cmd" key in the json output will include the command of the `x-scheme-handler/terminal` handler.
#[clap(verbatim_doc_comment)]
Get {
#[clap(long)]
/// Output handler info as json
#[clap(long)]
json: bool,
#[clap(add = ArgValueCompleter::new(autocomplete_mimes))]
/// Mimetype to get the handler of
#[clap(add = ArgValueCompleter::new(autocomplete_mimes))]
mime: MimeOrExtension,
#[command(flatten)]
selector_args: SelectorArgs,
Expand All @@ -175,11 +175,11 @@ pub enum Cmd {
/// This subcommand adds secondary handlers that coexist with the default
/// and does not overwrite existing handlers.
Add {
#[clap(add = ArgValueCompleter::new(autocomplete_mimes))]
/// Mimetype to add handler to
#[clap(add = ArgValueCompleter::new(autocomplete_mimes))]
mime: MimeOrExtension,
#[clap(add = ArgValueCompleter::new(autocomplete_desktop_files))]
/// Desktop file of handler program
#[clap(add = ArgValueCompleter::new(autocomplete_desktop_files))]
handler: DesktopHandler,
},

Expand All @@ -190,15 +190,14 @@ pub enum Cmd {
/// Literal wildcards (e.g. `text/*`) will be favored over matching mimetypes if present.
/// Otherwise, mimes matching wildcards (e.g. `text/plain`, etc.) will have their handlers removed.
Remove {
#[clap(add = ArgValueCompleter::new(autocomplete_mimes))]
/// Mimetype to remove handler from
#[clap(add = ArgValueCompleter::new(autocomplete_mimes))]
mime: MimeOrExtension,
#[clap(add = ArgValueCompleter::new(autocomplete_desktop_files))]
/// Desktop file of handler program to remove
#[clap(add = ArgValueCompleter::new(autocomplete_desktop_files))]
handler: DesktopHandler,
},

#[clap(verbatim_doc_comment)]
/// Get the mimetype of a given file/URL
///
/// By default, output is in the form of a table that matches file paths/URLs to their mimetypes.
Expand All @@ -216,6 +215,7 @@ pub enum Cmd {
/// },
/// ...
/// ]
#[clap(verbatim_doc_comment)]
Mime {
#[clap(required = true)]
/// File paths/URLs to get the mimetype of
Expand All @@ -228,15 +228,15 @@ pub enum Cmd {

#[derive(Clone, Args)]
pub struct SelectorArgs {
#[clap(long, short)]
/// Override the configured selector command
pub selector: Option<String>,
#[clap(long, short)]
pub selector: Option<String>,
/// Enable selector, overrides `enable_selector`
#[clap(long, short)]
pub enable_selector: bool,
/// Disable selector, overrides `enable_selector`
#[clap(long, short)]
#[clap(overrides_with = "enable_selector")]
/// Disable selector, overrides `enable_selector`
pub disable_selector: bool,
}

Expand Down

0 comments on commit 8b3f6f4

Please sign in to comment.