Enum handlr_regex::cli::Cmd

source ·
pub enum Cmd {
    List {
        all: bool,
    },
    Open {
        paths: Vec<UserPath>,
    },
    Set {
        mime: MimeOrExtension,
        handler: Handler,
    },
    Unset {
        mime: MimeOrExtension,
    },
    Launch {
        mime: MimeOrExtension,
        args: Vec<UserPath>,
    },
    Get {
        json: bool,
        mime: MimeOrExtension,
    },
    Add {
        mime: MimeOrExtension,
        handler: Handler,
    },
    Mime {
        json: bool,
        paths: Vec<UserPath>,
    },
    Autocomplete {
        desktop_files: bool,
        mimes: bool,
    },
}
Expand description

A better xdg-utils

Resource opener with support for wildcards, multiple handlers, and regular expressions.

Based on handlr at https://github.com/chmln/handlr

Regular expression handlers inspired by mimeo at https://xyne.dev/projects/mimeo/

Variants§

§

List

Fields

§all: bool

Expand wildcards in mimetypes and show global defaults

List default apps and the associated handlers

Output is formatted as a table with two columns. The left column shows mimetypes and the right column shows the handlers

Currently does not support regex handlers.

§

Open

Fields

§paths: Vec<UserPath>

Paths/URLs to open

Open a path/URL with its default handler

Unlike xdg-open and similar resource openers, multiple paths/URLs may be supplied.

If multiple handlers are set and enable_selector is set to true, you will be prompted to select one using selector from ~/.config/handlr/handlr.toml. Otherwise, the default handler will be opened.

§

Set

Fields

§mime: MimeOrExtension

Mimetype or file extension to operate on.

§handler: Handler

Desktop file of handler program

Set the default handler for mime/extension

Overwrites currently set handler(s) for the given mime/extension.

Asterisks can be used as wildcards to set multiple mimetypes.

File extensions are converted into their respective mimetypes in mimeapps.list.

Currently does not support regex handlers.

§

Unset

Fields

§mime: MimeOrExtension

Mimetype or file extension to unset the default handler of

Unset the default handler for mime/extension

Wildcards cannot be used unless removing handlers that already have wildcards.

If multiple default handlers are set, both will be removed.

Currently does not support regex handlers.

§

Launch

Fields

§mime: MimeOrExtension

Mimetype or file extension to launch the handler of

§args: Vec<UserPath>

Arguments to pass to handler program

Launch the handler for specified extension/mime with optional arguments

Only supports wildcards for mimetypes for handlers that have been set or added with wildcards.

If multiple handlers are set and enable_selector is set to true, you will be prompted to select one using selector from ~/.config/handlr/handlr.toml. Otherwise, the default handler will be opened.

§

Get

Fields

§json: bool

Output handler info as json

§mime: MimeOrExtension

Mimetype to get the handler of

Get handler for this mime/extension

If multiple handlers are set and enable_selector is set to true, you will be prompted to select one using selector from ~/.config/handlr/handlr.toml. Otherwise, only the default handler will be printed.

Note that regex handlers are not supported by this subcommand currently.

When using --json, output is in the form:


{

  "handler": "helix.desktop",

  "name": "Helix",

  "cmd": "helix"

}

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.

§

Add

Fields

§mime: MimeOrExtension

Mimetype to add handler to

§handler: Handler

Desktop file of handler program

Add a handler for given mime/extension

Note that the first handler is the default.

This subcommand adds secondary handlers that coexist with the default and does not overwrite existing handlers.

§

Mime

Fields

§json: bool

Output mimetype info as json

§paths: Vec<UserPath>

File paths/URLs to get the mimetype of

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.

When using --json, output will be in the form:


[

  {

    "path": "README.md"

    "mime": "text/markdown"

  },

  {

    "path": "https://duckduckgo.com/"

    "mime": "x-scheme-handler/https"

  }

...

]

§

Autocomplete

Fields

§desktop_files: bool

Autocomplete for desktop files present on system

§mimes: bool

Autocomplete for mimetypes/file extensions

Helper subcommand for autocompletion scripts; should be hidden

This should not be visible in handlr --help output, autocompletion, or man pages. If you see this there, please open an issue on Github.

However it is fine if this shows up in the output of handlr autocomplete --help.

Trait Implementations§

source§

impl CommandFactory for Cmd

source§

fn into_app<'b>() -> Command<'b>

Deprecated, replaced with CommandFactory::command
source§

fn into_app_for_update<'b>() -> Command<'b>

Deprecated, replaced with CommandFactory::command_for_update
source§

fn command<'help>() -> App<'help>

Build a Command that can instantiate Self. Read more
source§

fn command_for_update<'help>() -> App<'help>

Build a Command that can update self. Read more
source§

impl FromArgMatches for Cmd

source§

fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
source§

fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches ) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
source§

fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches ) -> Result<(), Error>

Assign values from ArgMatches to self.
source§

fn update_from_arg_matches_mut<'b>( &mut self, __clap_arg_matches: &mut ArgMatches ) -> Result<(), Error>

Assign values from ArgMatches to self.
source§

impl Parser for Cmd

source§

fn parse() -> Self

Parse from std::env::args_os(), exit on error
source§

fn try_parse() -> Result<Self, Error>

Parse from std::env::args_os(), return Err on error.
source§

fn parse_from<I, T>(itr: I) -> Selfwhere I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Parse from iterator, exit on error
source§

fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Parse from iterator, return Err on error.
source§

fn update_from<I, T>(&mut self, itr: I)where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Update from iterator, exit on error
source§

fn try_update_from<I, T>(&mut self, itr: I) -> Result<(), Error>where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Update from iterator, return Err on error.
source§

impl Subcommand for Cmd

source§

fn augment_subcommands<'b>(__clap_app: Command<'b>) -> Command<'b>

Append to Command so it can instantiate Self. Read more
source§

fn augment_subcommands_for_update<'b>(__clap_app: Command<'b>) -> Command<'b>

Append to Command so it can update self. Read more
source§

fn has_subcommand(__clap_name: &str) -> bool

Test whether Self can parse a specific subcommand

Auto Trait Implementations§

§

impl RefUnwindSafe for Cmd

§

impl Send for Cmd

§

impl Sync for Cmd

§

impl Unpin for Cmd

§

impl UnwindSafe for Cmd

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.