Revert "add auto-generated zsh completion"
This reverts commit dca0895b39.
This commit is contained in:
Generated
-10
@@ -67,15 +67,6 @@ dependencies = [
|
|||||||
"termcolor",
|
"termcolor",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "clap_complete"
|
|
||||||
version = "4.1.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0012995dc3a54314f4710f5631d74767e73c534b8757221708303e48eef7a19b"
|
|
||||||
dependencies = [
|
|
||||||
"clap",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_lex"
|
name = "clap_lex"
|
||||||
version = "0.3.1"
|
version = "0.3.1"
|
||||||
@@ -221,7 +212,6 @@ dependencies = [
|
|||||||
"alpm",
|
"alpm",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
"clap_complete",
|
|
||||||
"const_format",
|
"const_format",
|
||||||
"pacdef_macros",
|
"pacdef_macros",
|
||||||
"path-absolutize",
|
"path-absolutize",
|
||||||
|
|||||||
+112
@@ -0,0 +1,112 @@
|
|||||||
|
#compdef pacdef
|
||||||
|
|
||||||
|
_pacdef() {
|
||||||
|
integer ret=1
|
||||||
|
local line
|
||||||
|
|
||||||
|
if [ -z "${XDG_CONFIG_HOME}" ]; then
|
||||||
|
GROUPDIR="~/.config/pacdef/groups"
|
||||||
|
else
|
||||||
|
GROUPDIR="${XDG_CONFIG_HOME}/pacdef/groups"
|
||||||
|
fi
|
||||||
|
|
||||||
|
function _subcommands {
|
||||||
|
local -a subcommands
|
||||||
|
subcommands=(
|
||||||
|
'group:manage groups (alias: g)'
|
||||||
|
'package:manage packages (alias: p)'
|
||||||
|
'version:show version info (alias: v)'
|
||||||
|
)
|
||||||
|
_describe 'subcommand' subcommands
|
||||||
|
}
|
||||||
|
|
||||||
|
function _group_actions {
|
||||||
|
local -a group_actions
|
||||||
|
group_actions=(
|
||||||
|
'edit:edit an imported group file (alias: e)'
|
||||||
|
'list:show names of imported groups (alias: l)'
|
||||||
|
'import:import a new group file (alias: i)'
|
||||||
|
'new:create a new group file (alias: n)'
|
||||||
|
'remove:remove a group file (alias: r)'
|
||||||
|
'show:show packages under an imported group (alias: s)'
|
||||||
|
)
|
||||||
|
_describe 'group action' group_actions
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _package_actions {
|
||||||
|
local -a package_actions
|
||||||
|
package_actions=(
|
||||||
|
'clean:uninstall packages not managed by pacdef (alias: c)'
|
||||||
|
'review:review unmanaged packages (alias: r)'
|
||||||
|
'search:show the group containing a package (alias: se)'
|
||||||
|
'sync:install all packages from imported groups (alias: sy)'
|
||||||
|
'unmanaged:show explicitly installed packages not managed by pacdef (alias: u)'
|
||||||
|
)
|
||||||
|
_describe 'package action' package_actions
|
||||||
|
}
|
||||||
|
|
||||||
|
_arguments -C \
|
||||||
|
"1: :_subcommands" \
|
||||||
|
"*::arg:->args" \
|
||||||
|
&& ret=0
|
||||||
|
|
||||||
|
case $state in
|
||||||
|
(args)
|
||||||
|
case $line[1] in
|
||||||
|
package)
|
||||||
|
case $line[2] in
|
||||||
|
search)
|
||||||
|
_arguments \
|
||||||
|
"2:regex:" && ret=0
|
||||||
|
;;
|
||||||
|
(clean|review|sync|unmanaged|help)
|
||||||
|
_message "no more arguments" && ret=0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
_arguments \
|
||||||
|
"1: :_package_actions" \
|
||||||
|
"*::arg:->args" && ret=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
group)
|
||||||
|
case $line[2] in
|
||||||
|
list)
|
||||||
|
_message "no more arguments" && ret=0
|
||||||
|
;;
|
||||||
|
(edit|remove|show)
|
||||||
|
_arguments "*:group file:_files -W '$GROUPDIR'" && ret=0
|
||||||
|
|
||||||
|
;;
|
||||||
|
import)
|
||||||
|
_arguments "*:new group file(s):_files" && ret=0
|
||||||
|
;;
|
||||||
|
new)
|
||||||
|
_arguments \
|
||||||
|
{-e,--edit}"[edit group file after creating them]" \
|
||||||
|
"*:new group name(s):" \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
*) _arguments \
|
||||||
|
"1: :_group_actions" \
|
||||||
|
"*::arg:->args" && ret=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
version)
|
||||||
|
_message "no more arguments" && ret=0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
_message "unknown subcommand" && ret=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
_pacdef
|
||||||
|
|
||||||
|
|
||||||
@@ -27,4 +27,3 @@ serde_derive = "1.0"
|
|||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
|
|
||||||
pacdef_macros = { path = "../pacdef_macros", version = "0.1" }
|
pacdef_macros = { path = "../pacdef_macros", version = "0.1" }
|
||||||
clap_complete = "4.1.3"
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ use pacdef_macros::Action;
|
|||||||
#[derive(Debug, Action)]
|
#[derive(Debug, Action)]
|
||||||
pub enum Actions {
|
pub enum Actions {
|
||||||
Clean,
|
Clean,
|
||||||
Completion,
|
|
||||||
Edit,
|
Edit,
|
||||||
Import,
|
Import,
|
||||||
List,
|
List,
|
||||||
|
|||||||
@@ -9,18 +9,17 @@ use crate::core::get_version_string;
|
|||||||
|
|
||||||
/// Build the `pacdef` argument parser, with subcommands for `version`,
|
/// Build the `pacdef` argument parser, with subcommands for `version`,
|
||||||
/// `group` and `package`.
|
/// `group` and `package`.
|
||||||
pub fn build_cli() -> Command {
|
fn get_arg_parser() -> Command {
|
||||||
let package_cmd = get_package_cmd();
|
let package_cmd = get_package_cmd();
|
||||||
let group_cmd = get_group_cmd();
|
let group_cmd = get_group_cmd();
|
||||||
let version_cmd = Command::new(VERSION).about("show version info");
|
let version_cmd = Command::new(VERSION).about("show version info");
|
||||||
let completion_cmd = Command::new(COMPLETION).about("generate shell completion");
|
|
||||||
|
|
||||||
Command::new("pacdef")
|
Command::new("pacdef")
|
||||||
.about("declarative package manager for Linux")
|
.about("declarative package manager for Linux")
|
||||||
.version(get_version_string())
|
.version(get_version_string())
|
||||||
.subcommand_required(true)
|
.subcommand_required(true)
|
||||||
.arg_required_else_help(true)
|
.arg_required_else_help(true)
|
||||||
.subcommands([package_cmd, group_cmd, version_cmd, completion_cmd])
|
.subcommands([package_cmd, group_cmd, version_cmd])
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Build the `pacdef group` subcommand.
|
/// Build the `pacdef group` subcommand.
|
||||||
@@ -68,7 +67,7 @@ fn get_group_cmd() -> Command {
|
|||||||
|
|
||||||
Command::new("group")
|
Command::new("group")
|
||||||
.arg_required_else_help(true)
|
.arg_required_else_help(true)
|
||||||
.about("manage groups")
|
.about("TODO????")
|
||||||
.visible_alias("g")
|
.visible_alias("g")
|
||||||
.subcommand_required(true)
|
.subcommand_required(true)
|
||||||
.subcommands([edit, import, list, new, remove, show])
|
.subcommands([edit, import, list, new, remove, show])
|
||||||
@@ -96,7 +95,7 @@ fn get_package_cmd() -> Command {
|
|||||||
|
|
||||||
Command::new("package")
|
Command::new("package")
|
||||||
.arg_required_else_help(true)
|
.arg_required_else_help(true)
|
||||||
.about("manage packages")
|
.about("TODO????")
|
||||||
.visible_alias("p")
|
.visible_alias("p")
|
||||||
.subcommand_required(true)
|
.subcommand_required(true)
|
||||||
.subcommands([clean, review, unmanaged, search, sync])
|
.subcommands([clean, review, unmanaged, search, sync])
|
||||||
@@ -105,7 +104,7 @@ fn get_package_cmd() -> Command {
|
|||||||
/// Get and parse the CLI arguments.
|
/// Get and parse the CLI arguments.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn get() -> clap::ArgMatches {
|
pub fn get() -> clap::ArgMatches {
|
||||||
build_cli().get_matches()
|
get_arg_parser().get_matches()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// For each file argument, return the absolute path to the file.
|
/// For each file argument, return the absolute path to the file.
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ impl Pacdef {
|
|||||||
},
|
},
|
||||||
|
|
||||||
Some((VERSION, _)) => Ok(self.show_version()),
|
Some((VERSION, _)) => Ok(self.show_version()),
|
||||||
Some((COMPLETION, _)) => generate_shell_completion(),
|
|
||||||
|
|
||||||
Some((_, _)) => panic!("{ACTION_NOT_MATCHED}"),
|
Some((_, _)) => panic!("{ACTION_NOT_MATCHED}"),
|
||||||
None => unreachable!("{UNREACHABLE_ARM}"),
|
None => unreachable!("{UNREACHABLE_ARM}"),
|
||||||
|
|||||||
Reference in New Issue
Block a user