mirror of
https://github.com/narrrl/proton-drive-linux.git
synced 2026-11-13 01:27:03 +01:00
feat(cli,core): shell completions with live values from the service
`pdfs completions <shell>` prints a completion script for bash, zsh, fish, elvish or PowerShell, built on clap_complete's dynamic engine: on Tab the shell calls `pdfs` back, which completes commands and options and also the values the running service knows, each with a description: paths in My files, synced-folder and queue ids, computers, trash, albums, items shared with me, invitations, bookmarks, conflict copies, and a file's versions or a share's members and public link once its path is typed. A completer that gets no answer from the service within two seconds offers nothing rather than hanging the prompt. Listings that ask Proton are kept for 30 s in $XDG_RUNTIME_DIR (0600), so repeated Tabs do not wait again. Completion is triggered by PDFS_COMPLETE rather than clap's generic COMPLETE, because the same binary runs the daemon. Share roles are now checked by the CLI before the request. The package recipes install the bash, zsh and fish scripts via packaging/completions.sh.
This commit is contained in:
1 parent
ce35a83a04
commit
f25c2459a0
17 files changed
+971
-25
No files matched your search
@@ -80,5 +80,8 @@ package() {
|
||||
# Translations: compiled from po/ into /usr/share/locale.
|
||||
po/build.sh "$pkgdir/usr/share/locale"
|
||||
|
||||
# Shell completion for bash, zsh and fish.
|
||||
packaging/completions.sh "$rel/pdfs" "$pkgdir/usr/share"
|
||||
|
||||
install -Dm644 "LICENSE" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
|
||||
}
|
||||
@@ -64,6 +64,14 @@ package() {
|
||||
install -dm755 "$pkgdir/usr/share"
|
||||
cp -r --no-preserve=ownership "$srcdir/locale" "$pkgdir/usr/share/locale"
|
||||
|
||||
# Shell completion for bash, zsh and fish, written by the binary itself.
|
||||
local share="$pkgdir/usr/share"
|
||||
install -d "$share/bash-completion/completions" "$share/zsh/site-functions" \
|
||||
"$share/fish/vendor_completions.d"
|
||||
"$srcdir/pdfs" completions bash > "$share/bash-completion/completions/pdfs"
|
||||
"$srcdir/pdfs" completions zsh > "$share/zsh/site-functions/_pdfs"
|
||||
"$srcdir/pdfs" completions fish > "$share/fish/vendor_completions.d/pdfs.fish"
|
||||
|
||||
install -Dm644 "$srcdir/LICENSE-$pkgver" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
|
||||
|
||||
# pacman brings new releases, so the app never checks for them itself.
|
||||
|
||||
@@ -81,6 +81,9 @@ package() {
|
||||
# Translations: compiled from po/ into /usr/share/locale.
|
||||
po/build.sh "$pkgdir/usr/share/locale"
|
||||
|
||||
# Shell completion for bash, zsh and fish.
|
||||
packaging/completions.sh target/release/pdfs "$pkgdir/usr/share"
|
||||
|
||||
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
|
||||
install -Dm644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md"
|
||||
|
||||
|
||||
@@ -76,6 +76,9 @@ package() {
|
||||
# Translations: compiled from po/ into /usr/share/locale.
|
||||
po/build.sh "$pkgdir/usr/share/locale"
|
||||
|
||||
# Shell completion for bash, zsh and fish.
|
||||
packaging/completions.sh target/release/pdfs "$pkgdir/usr/share"
|
||||
|
||||
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
|
||||
install -Dm644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md"
|
||||
|
||||
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
# Write the shell completion scripts of a built `pdfs` into <datadir>, where
|
||||
# bash-completion, zsh and fish look for them. Packages pass their install
|
||||
# tree, e.g. "$pkgdir/usr/share". The scripts call `pdfs` from PATH on every
|
||||
# Tab, so they are the same for every version and need no rebuild per release.
|
||||
set -euo pipefail
|
||||
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "usage: $0 <pdfs binary> <datadir>" >&2
|
||||
exit 2
|
||||
fi
|
||||
pdfs="$1"
|
||||
datadir="$2"
|
||||
|
||||
install -d "$datadir/bash-completion/completions" \
|
||||
"$datadir/zsh/site-functions" \
|
||||
"$datadir/fish/vendor_completions.d"
|
||||
"$pdfs" completions bash > "$datadir/bash-completion/completions/pdfs"
|
||||
"$pdfs" completions zsh > "$datadir/zsh/site-functions/_pdfs"
|
||||
"$pdfs" completions fish > "$datadir/fish/vendor_completions.d/pdfs.fish"
|
||||
chmod 644 "$datadir/bash-completion/completions/pdfs" \
|
||||
"$datadir/zsh/site-functions/_pdfs" \
|
||||
"$datadir/fish/vendor_completions.d/pdfs.fish"
|
||||
@@ -40,6 +40,7 @@ rustPlatform.buildRustPackage {
|
||||
../io.narl.proton-drive-linux.desktop
|
||||
../io.narl.proton-drive-linux-tray.desktop
|
||||
../io.narl.proton-drive-linux.svg
|
||||
../completions.sh
|
||||
];
|
||||
};
|
||||
|
||||
@@ -107,6 +108,9 @@ rustPlatform.buildRustPackage {
|
||||
patchShebangs po/build.sh
|
||||
po/build.sh $out/share/locale
|
||||
|
||||
patchShebangs packaging/completions.sh
|
||||
packaging/completions.sh $out/bin/pdfs $out/share
|
||||
|
||||
# Nix brings new releases, so the app never checks for them itself.
|
||||
install -Dm644 /dev/null $out/share/proton-drive-linux/managed-updates
|
||||
'';
|
||||
|
||||
@@ -114,6 +114,7 @@ install -D -m0644 %{src}/packaging/io.narl.proton-drive-linux.svg \
|
||||
install -D -m0644 %{src}/packaging/proton-drive.service \
|
||||
%{buildroot}/usr/lib/systemd/user/proton-drive.service
|
||||
%{src}/po/build.sh %{buildroot}%{_datadir}/locale
|
||||
%{src}/packaging/completions.sh "$rel/pdfs" %{buildroot}%{_datadir}
|
||||
%if 0%{!?git_dir:1}
|
||||
# dnf brings new releases from COPR, so the app does not offer its own check.
|
||||
install -D -m0644 /dev/null %{buildroot}%{_datadir}/proton-drive-linux/managed-updates
|
||||
@@ -149,6 +150,9 @@ fi
|
||||
%{_datadir}/icons/hicolor/scalable/apps/io.narl.proton-drive-linux.svg
|
||||
/usr/lib/systemd/user/proton-drive.service
|
||||
%{_datadir}/locale/*/LC_MESSAGES/pdfs.mo
|
||||
%{_datadir}/bash-completion/completions/pdfs
|
||||
%{_datadir}/zsh/site-functions/_pdfs
|
||||
%{_datadir}/fish/vendor_completions.d/pdfs.fish
|
||||
%if 0%{!?git_dir:1}
|
||||
%{_datadir}/proton-drive-linux/managed-updates
|
||||
%endif
|
||||
|
||||
Reference in new issue
Block a user