clan-cli: shell completion for bash, zsh, fish
This commit is contained in:
parent
1e5cce99a9
commit
af7e4d7bb9
@ -1,6 +1,8 @@
|
|||||||
# !/usr/bin/env python3
|
# !/usr/bin/env python3
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
import argcomplete
|
||||||
|
|
||||||
import clan_admin
|
import clan_admin
|
||||||
|
|
||||||
|
|
||||||
@ -12,4 +14,6 @@ def clan() -> None:
|
|||||||
# init clan admin
|
# init clan admin
|
||||||
parser_admin = subparsers.add_parser("admin")
|
parser_admin = subparsers.add_parser("admin")
|
||||||
clan_admin.make_parser(parser_admin)
|
clan_admin.make_parser(parser_admin)
|
||||||
|
argcomplete.autocomplete(parser)
|
||||||
|
parser.parse_args()
|
||||||
|
|
||||||
|
@ -1,20 +1,21 @@
|
|||||||
{
|
{ pkgs ? import <nixpkgs> { }
|
||||||
pkgs ? import <nixpkgs> {},
|
, lib ? pkgs.lib
|
||||||
|
, python3 ? pkgs.python3
|
||||||
lib ? pkgs.lib,
|
, ruff ? pkgs.ruff
|
||||||
python3 ? pkgs.python3,
|
, runCommand ? pkgs.runCommand
|
||||||
ruff ? pkgs.ruff,
|
, installShellFiles ? pkgs.installShellFiles
|
||||||
runCommand ? pkgs.runCommand,
|
,
|
||||||
}: let
|
}:
|
||||||
|
let
|
||||||
pyproject = builtins.fromTOML (builtins.readFile ./pyproject.toml);
|
pyproject = builtins.fromTOML (builtins.readFile ./pyproject.toml);
|
||||||
name = pyproject.project.name;
|
name = pyproject.project.name;
|
||||||
|
|
||||||
src = lib.cleanSource ./.;
|
src = lib.cleanSource ./.;
|
||||||
|
|
||||||
dependencies = lib.attrValues {
|
dependencies = lib.attrValues {
|
||||||
# inherit (python3.pkgs)
|
inherit (python3.pkgs)
|
||||||
# some-package
|
argcomplete
|
||||||
# ;
|
;
|
||||||
};
|
};
|
||||||
|
|
||||||
devDependencies = lib.attrValues {
|
devDependencies = lib.attrValues {
|
||||||
@ -34,15 +35,22 @@
|
|||||||
format = "pyproject";
|
format = "pyproject";
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
python3.pkgs.setuptools
|
python3.pkgs.setuptools
|
||||||
|
installShellFiles
|
||||||
];
|
];
|
||||||
propagatedBuildInputs =
|
propagatedBuildInputs =
|
||||||
dependencies
|
dependencies
|
||||||
++ [ ];
|
++ [ ];
|
||||||
passthru.tests = { inherit check; };
|
passthru.tests = { inherit check; };
|
||||||
passthru.devDependencies = devDependencies;
|
passthru.devDependencies = devDependencies;
|
||||||
|
postInstall = ''
|
||||||
|
installShellCompletion --bash --name clan \
|
||||||
|
<(${python3.pkgs.argcomplete}/bin/register-python-argcomplete --shell bash clan)
|
||||||
|
installShellCompletion --fish --name clan.fish \
|
||||||
|
<(${python3.pkgs.argcomplete}/bin/register-python-argcomplete --shell fish clan)
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
checkPython = python3.withPackages (ps: devDependencies);
|
checkPython = python3.withPackages (ps: devDependencies ++ dependencies);
|
||||||
|
|
||||||
check = runCommand "${name}-check" { } ''
|
check = runCommand "${name}-check" { } ''
|
||||||
cp -r ${src} ./src
|
cp -r ${src} ./src
|
||||||
|
@ -32,6 +32,10 @@ ignore_missing_imports = true
|
|||||||
module = "pytest.*"
|
module = "pytest.*"
|
||||||
ignore_missing_imports = true
|
ignore_missing_imports = true
|
||||||
|
|
||||||
|
[[tool.mypy.overrides]]
|
||||||
|
module = "argcomplete.*"
|
||||||
|
ignore_missing_imports = true
|
||||||
|
|
||||||
[tool.ruff]
|
[tool.ruff]
|
||||||
line-length = 88
|
line-length = 88
|
||||||
|
|
||||||
|
@ -41,6 +41,15 @@ let
|
|||||||
|
|
||||||
export PATH="$tmp_path/bin:${checkScript}/bin:$PATH"
|
export PATH="$tmp_path/bin:${checkScript}/bin:$PATH"
|
||||||
export PYTHONPATH="$repo_root:$tmp_path/${pythonWithDeps.sitePackages}"
|
export PYTHONPATH="$repo_root:$tmp_path/${pythonWithDeps.sitePackages}"
|
||||||
|
|
||||||
|
export XDG_DATA_DIRS="$tmp_path/share''${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}"
|
||||||
|
export fish_complete_path="$tmp_path/share/fish/vendor_completions.d''${fish_complete_path:+:$fish_complete_path}"
|
||||||
|
mkdir -p \
|
||||||
|
$tmp_path/share/fish/vendor_completions.d \
|
||||||
|
$tmp_path/share/bash-completion/completions \
|
||||||
|
$tmp_path/share/zsh/site-functions
|
||||||
|
register-python-argcomplete --shell fish clan > $tmp_path/share/fish/vendor_completions.d/clan.fish
|
||||||
|
register-python-argcomplete --shell bash clan > $tmp_path/share/bash-completion/completions/clan
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
Loading…
Reference in New Issue
Block a user