mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-25 14:05:41 -05:00
Add value hints for clap file paths
This ensures that the generated completions properly suggest file paths for arguments which accept them.
This commit is contained in:
parent
ff7f74fd29
commit
9f02fb9568
5 changed files with 43 additions and 42 deletions
32
Cargo.lock
generated
32
Cargo.lock
generated
|
@ -168,16 +168,16 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "3.0.3"
|
||||
version = "3.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "17a98d95cbe8abdf3bfe1a2bd4aa7215700403b79a0eb03cbddb017a5824e186"
|
||||
checksum = "d53da17d37dba964b9b3ecb5c5a1f193a2762c700e6829201e645b9381c99dc7"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"bitflags",
|
||||
"clap_derive",
|
||||
"clap_lex",
|
||||
"indexmap",
|
||||
"lazy_static",
|
||||
"os_str_bytes",
|
||||
"once_cell",
|
||||
"strsim",
|
||||
"termcolor",
|
||||
"textwrap",
|
||||
|
@ -185,18 +185,18 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "clap_complete"
|
||||
version = "3.0.2"
|
||||
version = "3.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a394f7ec0715b42a4e52b294984c27c9a61f77c8d82f7774c5198350be143f19"
|
||||
checksum = "0f6ebaab5f25e4f0312dfa07cb30a755204b96e6531457c2cfdecfdf5f2adf40"
|
||||
dependencies = [
|
||||
"clap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "3.0.2"
|
||||
version = "3.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "448c8b00367288ad41804ac7a9e0fe58f2324a36901cb5d6b6db58be86d1db8f"
|
||||
checksum = "c11d40217d16aee8508cc8e5fde8b4ff24639758608e5374e731b53f85749fb9"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro-error",
|
||||
|
@ -205,6 +205,15 @@ dependencies = [
|
|||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5538cd660450ebeb4234cfecf8f2284b844ffc4c50531e66d584ad5b91293613"
|
||||
dependencies = [
|
||||
"os_str_bytes",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clipboard-win"
|
||||
version = "3.1.1"
|
||||
|
@ -1201,9 +1210,6 @@ name = "os_str_bytes"
|
|||
version = "6.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "osmesa-sys"
|
||||
|
@ -1573,9 +1579,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.14.2"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80"
|
||||
checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::path::PathBuf;
|
|||
|
||||
#[cfg(unix)]
|
||||
use clap::Subcommand;
|
||||
use clap::{Args, Parser};
|
||||
use clap::{Args, Parser, ValueHint};
|
||||
use log::{self, error, LevelFilter};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_yaml::Value;
|
||||
|
@ -31,22 +31,22 @@ pub struct Options {
|
|||
|
||||
/// Specify alternative configuration file [default: $XDG_CONFIG_HOME/alacritty/alacritty.yml].
|
||||
#[cfg(not(any(target_os = "macos", windows)))]
|
||||
#[clap(long)]
|
||||
#[clap(long, value_hint = ValueHint::FilePath)]
|
||||
pub config_file: Option<PathBuf>,
|
||||
|
||||
/// Specify alternative configuration file [default: %APPDATA%\alacritty\alacritty.yml].
|
||||
#[cfg(windows)]
|
||||
#[clap(long)]
|
||||
#[clap(long, value_hint = ValueHint::FilePath)]
|
||||
pub config_file: Option<PathBuf>,
|
||||
|
||||
/// Specify alternative configuration file [default: $HOME/.config/alacritty/alacritty.yml].
|
||||
#[cfg(target_os = "macos")]
|
||||
#[clap(long)]
|
||||
#[clap(long, value_hint = ValueHint::FilePath)]
|
||||
pub config_file: Option<PathBuf>,
|
||||
|
||||
/// Path for IPC socket creation.
|
||||
#[cfg(unix)]
|
||||
#[clap(long)]
|
||||
#[clap(long, value_hint = ValueHint::FilePath)]
|
||||
pub socket: Option<PathBuf>,
|
||||
|
||||
/// Reduces the level of verbosity (the min level is -qq).
|
||||
|
@ -177,7 +177,7 @@ fn parse_class(input: &str) -> Result<Class, String> {
|
|||
#[derive(Serialize, Deserialize, Args, Default, Debug, Clone, PartialEq, Eq)]
|
||||
pub struct TerminalOptions {
|
||||
/// Start the shell in the specified working directory.
|
||||
#[clap(long)]
|
||||
#[clap(long, value_hint = ValueHint::FilePath)]
|
||||
pub working_directory: Option<PathBuf>,
|
||||
|
||||
/// Remain open after child process exit.
|
||||
|
@ -260,7 +260,7 @@ pub enum Subcommands {
|
|||
#[derive(Args, Debug)]
|
||||
pub struct MessageOptions {
|
||||
/// IPC socket connection path override.
|
||||
#[clap(long, short)]
|
||||
#[clap(long, short, value_hint = ValueHint::FilePath)]
|
||||
pub socket: Option<PathBuf>,
|
||||
|
||||
/// Message which should be sent.
|
||||
|
|
|
@ -16,11 +16,11 @@ _alacritty() {
|
|||
local context curcontext="$curcontext" state line
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'--embed=[Defines the X11 window ID (as a decimal integer) to embed Alacritty within]:EMBED: ' \
|
||||
'--config-file=[Specify alternative configuration file \[default: $XDG_CONFIG_HOME/alacritty/alacritty.yml\]]:CONFIG_FILE: ' \
|
||||
'--socket=[Path for IPC socket creation]:SOCKET: ' \
|
||||
'--config-file=[Specify alternative configuration file \[default: $XDG_CONFIG_HOME/alacritty/alacritty.yml\]]:CONFIG_FILE:_files' \
|
||||
'--socket=[Path for IPC socket creation]:SOCKET:_files' \
|
||||
'*-o+[Override configuration file options \[example: cursor.style=Beam\]]:OPTION: ' \
|
||||
'*--option=[Override configuration file options \[example: cursor.style=Beam\]]:OPTION: ' \
|
||||
'--working-directory=[Start the shell in the specified working directory]:WORKING_DIRECTORY: ' \
|
||||
'--working-directory=[Start the shell in the specified working directory]:WORKING_DIRECTORY:_files' \
|
||||
'*-e+[Command and args to execute (must be last argument)]:COMMAND: ' \
|
||||
'*--command=[Command and args to execute (must be last argument)]:COMMAND: ' \
|
||||
'-t+[Defines the window title \[default: Alacritty\]]:TITLE: ' \
|
||||
|
@ -46,8 +46,8 @@ _alacritty() {
|
|||
case $line[1] in
|
||||
(msg)
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'-s+[IPC socket connection path override]:SOCKET: ' \
|
||||
'--socket=[IPC socket connection path override]:SOCKET: ' \
|
||||
'-s+[IPC socket connection path override]:SOCKET:_files' \
|
||||
'--socket=[IPC socket connection path override]:SOCKET:_files' \
|
||||
'-h[Print help information]' \
|
||||
'--help[Print help information]' \
|
||||
":: :_alacritty__msg_commands" \
|
||||
|
@ -62,13 +62,12 @@ _arguments "${_arguments_options[@]}" \
|
|||
case $line[1] in
|
||||
(create-window)
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'--working-directory=[Start the shell in the specified working directory]:WORKING_DIRECTORY: ' \
|
||||
'--working-directory=[Start the shell in the specified working directory]:WORKING_DIRECTORY:_files' \
|
||||
'*-e+[Command and args to execute (must be last argument)]:COMMAND: ' \
|
||||
'*--command=[Command and args to execute (must be last argument)]:COMMAND: ' \
|
||||
'-t+[Defines the window title \[default: Alacritty\]]:TITLE: ' \
|
||||
'--title=[Defines the window title \[default: Alacritty\]]:TITLE: ' \
|
||||
'--class=[Defines window class/app_id on X11/Wayland \[default: Alacritty\]]:instance> | <instance>,<general: ' \
|
||||
'--version[Print version information]' \
|
||||
'--hold[Remain open after child process exit]' \
|
||||
'-h[Print help information]' \
|
||||
'--help[Print help information]' \
|
||||
|
@ -76,9 +75,7 @@ _arguments "${_arguments_options[@]}" \
|
|||
;;
|
||||
(help)
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'--version[Print version information]' \
|
||||
'-h[Print help information]' \
|
||||
'--help[Print help information]' \
|
||||
'*::subcommand -- The subcommand whose help message to display:' \
|
||||
&& ret=0
|
||||
;;
|
||||
esac
|
||||
|
@ -87,6 +84,7 @@ esac
|
|||
;;
|
||||
(help)
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'*::subcommand -- The subcommand whose help message to display:' \
|
||||
&& ret=0
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -86,7 +86,7 @@ _alacritty() {
|
|||
return 0
|
||||
;;
|
||||
alacritty__help)
|
||||
opts=""
|
||||
opts="<SUBCOMMAND>..."
|
||||
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
||||
return 0
|
||||
|
@ -122,7 +122,7 @@ _alacritty() {
|
|||
return 0
|
||||
;;
|
||||
alacritty__msg__create__window)
|
||||
opts="-e -t -h --version --working-directory --hold --command --title --class --help"
|
||||
opts="-e -t -h --working-directory --hold --command --title --class --help"
|
||||
if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
||||
return 0
|
||||
|
@ -160,7 +160,7 @@ _alacritty() {
|
|||
return 0
|
||||
;;
|
||||
alacritty__msg__help)
|
||||
opts="-h --version --help"
|
||||
opts="<SUBCOMMAND>..."
|
||||
if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
||||
return 0
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
complete -c alacritty -n "__fish_use_subcommand" -l embed -d 'Defines the X11 window ID (as a decimal integer) to embed Alacritty within' -r
|
||||
complete -c alacritty -n "__fish_use_subcommand" -l config-file -d 'Specify alternative configuration file [default: $XDG_CONFIG_HOME/alacritty/alacritty.yml]' -r
|
||||
complete -c alacritty -n "__fish_use_subcommand" -l socket -d 'Path for IPC socket creation' -r
|
||||
complete -c alacritty -n "__fish_use_subcommand" -l config-file -d 'Specify alternative configuration file [default: $XDG_CONFIG_HOME/alacritty/alacritty.yml]' -r -F
|
||||
complete -c alacritty -n "__fish_use_subcommand" -l socket -d 'Path for IPC socket creation' -r -F
|
||||
complete -c alacritty -n "__fish_use_subcommand" -s o -l option -d 'Override configuration file options [example: cursor.style=Beam]' -r
|
||||
complete -c alacritty -n "__fish_use_subcommand" -l working-directory -d 'Start the shell in the specified working directory' -r
|
||||
complete -c alacritty -n "__fish_use_subcommand" -l working-directory -d 'Start the shell in the specified working directory' -r -F
|
||||
complete -c alacritty -n "__fish_use_subcommand" -s e -l command -d 'Command and args to execute (must be last argument)' -r
|
||||
complete -c alacritty -n "__fish_use_subcommand" -s t -l title -d 'Defines the window title [default: Alacritty]' -r
|
||||
complete -c alacritty -n "__fish_use_subcommand" -l class -d 'Defines window class/app_id on X11/Wayland [default: Alacritty]' -r
|
||||
|
@ -15,16 +15,13 @@ complete -c alacritty -n "__fish_use_subcommand" -s v -d 'Increases the level of
|
|||
complete -c alacritty -n "__fish_use_subcommand" -l hold -d 'Remain open after child process exit'
|
||||
complete -c alacritty -n "__fish_use_subcommand" -f -a "msg" -d 'Send a message to the Alacritty socket'
|
||||
complete -c alacritty -n "__fish_use_subcommand" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
|
||||
complete -c alacritty -n "__fish_seen_subcommand_from msg; and not __fish_seen_subcommand_from create-window; and not __fish_seen_subcommand_from help" -s s -l socket -d 'IPC socket connection path override' -r
|
||||
complete -c alacritty -n "__fish_seen_subcommand_from msg; and not __fish_seen_subcommand_from create-window; and not __fish_seen_subcommand_from help" -s s -l socket -d 'IPC socket connection path override' -r -F
|
||||
complete -c alacritty -n "__fish_seen_subcommand_from msg; and not __fish_seen_subcommand_from create-window; and not __fish_seen_subcommand_from help" -s h -l help -d 'Print help information'
|
||||
complete -c alacritty -n "__fish_seen_subcommand_from msg; and not __fish_seen_subcommand_from create-window; and not __fish_seen_subcommand_from help" -f -a "create-window" -d 'Create a new window in the same Alacritty process'
|
||||
complete -c alacritty -n "__fish_seen_subcommand_from msg; and not __fish_seen_subcommand_from create-window; and not __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
|
||||
complete -c alacritty -n "__fish_seen_subcommand_from msg; and __fish_seen_subcommand_from create-window" -l working-directory -d 'Start the shell in the specified working directory' -r
|
||||
complete -c alacritty -n "__fish_seen_subcommand_from msg; and __fish_seen_subcommand_from create-window" -l working-directory -d 'Start the shell in the specified working directory' -r -F
|
||||
complete -c alacritty -n "__fish_seen_subcommand_from msg; and __fish_seen_subcommand_from create-window" -s e -l command -d 'Command and args to execute (must be last argument)' -r
|
||||
complete -c alacritty -n "__fish_seen_subcommand_from msg; and __fish_seen_subcommand_from create-window" -s t -l title -d 'Defines the window title [default: Alacritty]' -r
|
||||
complete -c alacritty -n "__fish_seen_subcommand_from msg; and __fish_seen_subcommand_from create-window" -l class -d 'Defines window class/app_id on X11/Wayland [default: Alacritty]' -r
|
||||
complete -c alacritty -n "__fish_seen_subcommand_from msg; and __fish_seen_subcommand_from create-window" -l version -d 'Print version information'
|
||||
complete -c alacritty -n "__fish_seen_subcommand_from msg; and __fish_seen_subcommand_from create-window" -l hold -d 'Remain open after child process exit'
|
||||
complete -c alacritty -n "__fish_seen_subcommand_from msg; and __fish_seen_subcommand_from create-window" -s h -l help -d 'Print help information'
|
||||
complete -c alacritty -n "__fish_seen_subcommand_from msg; and __fish_seen_subcommand_from help" -l version -d 'Print version information'
|
||||
complete -c alacritty -n "__fish_seen_subcommand_from msg; and __fish_seen_subcommand_from help" -s h -l help -d 'Print help information'
|
||||
|
|
Loading…
Reference in a new issue