fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Fabian Boehmcompletions/flatpak: Fix broken cache usage8bf416cd6

master
4.1 KiB69 linesraw
1# Completions for flatpak, an "Application deployment framework for desktop apps"
2
3function __fish_flatpak_subcommands
4    printf "%s\n" \
5        build-bundle\t"Create a bundle file from a build directory" \
6        build-commit-from\t"Create new commit based on existing ref" \
7        build-export\t"Export a build dir to a repository" \
8        build-finish\t"Finish a build dir for export" \
9        build-import-bundle\t"Import a bundle file" \
10        build-init\t"Initialize a directory for building" \
11        build-sign\t"Sign an application or runtime" \
12        build-update-repo\t"Update the summary file in a repository" \
13        build\t"Run a build command inside the build dir" \
14        config\t"Configure flatpak" \
15        create-usb\t"Put applications or runtimes onto removable media" \
16        document-export\t"Grant an application access to a specific file" \
17        document-info\t"Show information about a specific file" \
18        document-unexport\t"Revoke access to a specific file" \
19        documents\t"List exported files" \
20        enter\t"Enter the namespace of a running application" \
21        history\t"Show history" \
22        info\t"Show info for installed app or runtime" \
23        install\t"Install an application or runtime from a remote" \
24        kill\t"Stop a running application" \
25        list\t"List installed apps and/or runtimes" \
26        make-current\t"Specify default version to run" \
27        mask\t"Mask out updates and automatic installation" \
28        override\t"Override permissions for an application" \
29        permission-remove\t"Remove item from permission store" \
30        permission-reset\t"Reset app permissions" \
31        permission-set\t"Set permissions" \
32        permission-show\t"Show app permissions" \
33        permissions\t"List permissions" \
34        ps\t"Enumerate running applications" \
35        remote-add\t"Add a new remote repository (by URL)" \
36        remote-delete\t"Delete a configured remote" \
37        remote-info\t"Show information about a remote app or runtime" \
38        remote-ls\t"List contents of a configured remote" \
39        remote-modify\t"Modify properties of a configured remote" \
40        remotes\t"List all configured remotes" \
41        repair\t"Repair flatpak installation" \
42        repo\t"Show information about a repo" \
43        run\t"Run an application" \
44        search\t"Search for remote apps/runtimes" \
45        uninstall\t"Uninstall an installed application or runtime" \
46        update\t"Update an installed application or runtime"
47end
48complete -c flatpak -n __fish_is_first_token -xa "(__fish_flatpak_subcommands)"
49
50# A flatpak bug on some systems seems to cause it to assume output is a tty and always emit pretty-formatted output, with
51# a variable number of spaces for alignment, trailing CR, and ANSI formatting sequences (see #10514).
52#
53# This wrapper function is akin to `flatpak $argv[1] $argv[2..]` but sanitizes the output to make it completion-friendly.
54function __fish_flatpak
55    # We can't rely on the first line being the headers because modern flatpak will omit it when running in a "subshell".
56    # Based off our invocations, we expect the first column of actual output to never contain a capitalized letter
57    # (unlike the header row).
58    flatpak $argv | string replace -rf '^([^A-Z].*?)(?: +|\t)(.*?)\s*$' '$1\t$2'
59end
60
61complete -f -c flatpak -n "__fish_seen_subcommand_from run" -a "(__fish_flatpak list --app --columns=application,name)"
62complete -f -c flatpak -n "__fish_seen_subcommand_from info uninstall" -a "(__fish_flatpak list --columns=application,name)"
63complete -f -c flatpak -n "__fish_seen_subcommand_from enter kill" -a "(__fish_flatpak ps --columns=instance,application)"
64complete -f -c flatpak -n "__fish_seen_subcommand_from remote-info remote-ls remote-modify remote-delete" -a "(__fish_flatpak remotes --columns=name,title)"
65
66complete -c flatpak -n '__fish_seen_subcommand_from install' -xa "(__fish_cached -t 250 -- 'flatpak remote-ls --columns=application,name' | string replace -rf '^([^A-Z].*?)(?: +|\t)(.*?)\s*\$' '\$1\t\$2')"
67
68# Plenty of the other stuff is too free-form to complete (e.g. remote-add).
69complete -f -c flatpak -s h -l help