fish-shell/share/completions/snap.fish

278 lines
11 KiB
Fish
Raw Normal View History

2017-07-14 19:59:56 +08:00
# Completions for `snap` command
function __fish_snap_no_subcommand -d 'Test if snap has yet to be given the subcommand'
for i in (commandline -xpc)
if contains -- $i abort ack alias aliases buy changes connect disable disconnect download \
enable find get help info install interfaces known list login logout prefer refresh remove \
revert run set tasks try unalias version watch
return 1
end
end
return 0
2017-07-14 19:59:56 +08:00
end
function __fish_snap_using_subcommand -d 'Test if given subcommand is used'
for i in (commandline -xpc)
2017-07-14 19:59:56 +08:00
if contains -- $i $argv[1]
return 0
end
end
return 1
end
function __fish_snap_use_file -d 'Test if snap command should have files as potential completion'
for i in (commandline -xpc)
if contains -- $i ack try
return 0
end
end
return 1
2017-07-14 19:59:56 +08:00
end
function __fish_snap_subcommand
set -l subcommand $argv[1]
set -e argv[1]
complete -f -c snap -n __fish_snap_no_subcommand -a $subcommand $argv
2017-07-14 19:59:56 +08:00
end
function __fish_snap_option
set -l subcommand $argv[1]
set -e argv[1]
2017-07-14 19:59:56 +08:00
complete -f -c snap -n "__fish_snap_using_subcommand $subcommand" $argv
end
function __fish_snap_disabled_snaps -d 'List disabled snaps'
2017-07-14 19:59:56 +08:00
snap list | string match "*disabled" | string replace -r '(.+?) .*disabled' '$1'
end
function __fish_snap_enabled_snaps -d 'List disabled snaps'
2017-07-14 19:59:56 +08:00
snap list | string match -vr "disabled|Name" | string replace -r '(.+?) .*' '$1'
end
function __fish_snap_installed_snaps -d 'List installed snaps'
2017-07-14 19:59:56 +08:00
snap list | string replace -r '(.+?) .*' '$1' | string match -v 'Name*'
end
function __fish_snap_interfaces -d 'List of interfaces'
2017-07-14 19:59:56 +08:00
for snap in (__fish_snap_installed_snaps)
if test $snap != core
snap interfaces $snap 2>/dev/null | string replace -r '[- ]*([^ ]*)[ ]+([^ ]+)' '$2$1' | string match -v "*Slot*"
2017-07-14 19:59:56 +08:00
end
end
end
function __fish_snap_change_id -d 'List change IDs'
2017-07-14 19:59:56 +08:00
snap changes | string match -v 'ID*' | string replace -r '([0-9]*) .*' '$1'
end
function __fish_snap_aliases -d 'List aliases'
2017-07-14 19:59:56 +08:00
snap aliases | string match -v 'Command*' | string replace -r '.* (.+?) .*$' '$1'
snap aliases | string match -v 'Command*' | string replace -r '(.*?) .*$' '$1'
end
function __fish_snap_no_assertion -d 'Check that no assertion type is used yet'
for i in (commandline -xpc)
if contains -- $i account account-key model serial snap-declaration snap-build snap-revision \
system-user validation
return 1
end
end
return 0
2017-07-14 19:59:56 +08:00
end
function __fish_snap_using_assertion -d 'Check if certain assertion type is used'
2017-07-14 19:59:56 +08:00
if __fish_snap_using_subcommand known
if __fish_snap_using_subcommand $argv[1]
return 0
end
end
return 1
end
function __fish_snap_assertion
set -l assertion $argv[1]
set -e argv[1]
2017-07-14 19:59:56 +08:00
complete -f -c snap -n '__fish_snap_using_subcommand known; and __fish_snap_no_assertion' -a $assertion
complete -f -c snap -n "__fish_snap_using_assertion $assertion" -a "(__fish_snap_filters $assertion)" \
-d Filter
2017-07-14 19:59:56 +08:00
end
function __fish_snap_filters -d 'List assertion filters'
2017-07-14 19:59:56 +08:00
snap known $argv[1] | string match -v 'type:*' | string match '*: *' | string replace -r '(.*): (.*)' '$1=$2'
end
# Enable file completions where appropriate
complete -c snap -n __fish_snap_use_file -a '(__fish_complete_path)'
2017-07-14 19:59:56 +08:00
# Support flags
complete -x -f -c snap -s h -l help -d 'Show this help message'
complete -x -f -c snap -s v -l version -d 'Print the version and exit'
2017-07-14 19:59:56 +08:00
# Abort
__fish_snap_subcommand abort -d "Abort a pending change"
2017-07-14 19:59:56 +08:00
# Ack
__fish_snap_subcommand ack -r -d "Adds an assertion to the system"
2017-07-14 19:59:56 +08:00
# Alias
__fish_snap_subcommand alias -r -d "Sets up a manual alias"
__fish_snap_option alias -a '(__fish_snap_installed_snaps)' -d Snap
2017-07-14 19:59:56 +08:00
# Aliases
__fish_snap_subcommand aliases -d "Lists aliases in the system"
2017-07-14 19:59:56 +08:00
# Buy
__fish_snap_subcommand buy -r -d "Buys a snap"
2017-07-14 19:59:56 +08:00
# Changes
__fish_snap_subcommand changes -d "List system changes"
2017-07-14 19:59:56 +08:00
# Connect
__fish_snap_subcommand connect -r -d "Connects a plug to a slot"
__fish_snap_option connect -a '(__fish_snap_interfaces)' -d "Snap:Plug or Slot"
2017-07-14 19:59:56 +08:00
# Disable
__fish_snap_subcommand disable -r -d "Disables a snap in the system"
__fish_snap_option disable -a '(__fish_snap_enabled_snaps)' -d "Enabled snap"
2017-07-14 19:59:56 +08:00
# Disconnect
__fish_snap_subcommand disconnect -r -d "Disconnects a plug from a slot"
__fish_snap_option disconnect -a '(__fish_snap_interfaces)' -d "Snap:Plug or Slot"
2017-07-14 19:59:56 +08:00
# Downloads
__fish_snap_subcommand download -r -d "Downloads the given snap"
__fish_snap_option download -l channel -d "Use this channel instead of stable"
__fish_snap_option download -l edge -d "Install from the edge channel"
__fish_snap_option download -l beta -d "Install from the beta channel"
__fish_snap_option download -l candidate -d "Install from the candidate channel"
__fish_snap_option download -l stable -d "Install from the stable channel"
__fish_snap_option download -l revision -d "Download the given revision of snap, to which you must have developer access"
2017-07-14 19:59:56 +08:00
# Enable
__fish_snap_subcommand enable -r -d "Enables a snap in the system"
__fish_snap_option enable -a '(__fish_snap_disabled_snaps)' -d "Disabled snap"
2017-07-14 19:59:56 +08:00
# Find
__fish_snap_subcommand find -r -d "Finds packages to install"
__fish_snap_option find -l private -d "Search private snaps"
__fish_snap_option find -l section -d "Restrict the search to a given section"
2017-07-14 19:59:56 +08:00
# There seems to be no programmatic way of getting configuration options
# Get
__fish_snap_subcommand get -r -d "Prints configuration options"
__fish_snap_option get -s t -d "Strict typing with nulls and quoted strings"
__fish_snap_option get -s d -d "Always return documents, even with single key"
__fish_snap_option get -a '(__fish_snap_installed_snaps)' -d Snap
2017-07-14 19:59:56 +08:00
# Help
__fish_snap_subcommand help -d "The help command shows useful information"
__fish_snap_option help -l man -d "Generates the manpage"
2017-07-14 19:59:56 +08:00
# Info
__fish_snap_subcommand info -r -d "Show detailed information about a snap"
__fish_snap_option info -l verbose -d "Include a verbose list of snap's notes"
__fish_snap_option info -a '(__fish_snap_installed_snaps)' -d Snap
2017-07-14 19:59:56 +08:00
# Install
__fish_snap_subcommand install -r -d "Installs a snap to the system"
__fish_snap_option install -l channel -d "Use this channel instead of stable"
__fish_snap_option install -l edge -d "Install from the edge channel"
__fish_snap_option install -l beta -d "Install from the beta channel"
__fish_snap_option install -l candidate -d "Install from the candidate channel"
__fish_snap_option install -l stable -d "Install from the stable channel"
__fish_snap_option install -l revision -d "Install the given revision of snap, to which you must have developer access"
__fish_snap_option install -l devmode -d "Put snap in development mode and disable security confinement"
__fish_snap_option install -l jailmode -d "Put snap in enforced confinement mode"
__fish_snap_option install -l classic -d "Put snap in classic mode and disable security confinement"
__fish_snap_option install -l dangerous -d "Install the given snap even without pre-acknowledged signatures (DANGEROUS)"
2017-07-14 19:59:56 +08:00
# Interfaces
__fish_snap_subcommand interfaces -d "Lists interfaces in the system"
complete -f -c snap -n '__fish_snap_using_subcommand interfaces' -a '(__fish_snap_installed_snaps)' -d Snap
__fish_snap_option interfaces -s i -d "Constrain listing to specific interfaces"
2017-07-14 19:59:56 +08:00
# Known
__fish_snap_subcommand known -r -d "Shows known assertions of the provided type"
__fish_snap_option known -l remote -d "Shows known assertions of the provided type"
__fish_snap_assertion account -d 'Assertion type'
__fish_snap_assertion account-key -d 'Assertion type'
__fish_snap_assertion model -d 'Assertion type'
__fish_snap_assertion serial -d 'Assertion type'
__fish_snap_assertion snap-declaration -d 'Assertion type'
__fish_snap_assertion snap-build -d 'Assertion type'
__fish_snap_assertion snap-revision -d 'Assertion type'
__fish_snap_assertion system-user -d 'Assertion type'
__fish_snap_assertion validation -d 'Assertion type'
2017-07-14 19:59:56 +08:00
# List
__fish_snap_subcommand list -d "List installed snaps"
__fish_snap_option list -l all -d "Show all revisions"
2017-07-14 19:59:56 +08:00
# Login
__fish_snap_subcommand login -d "Authenticates on snapd and the store"
2017-07-14 19:59:56 +08:00
# Logout
__fish_snap_subcommand logout -d "Log out of the store"
2017-07-14 19:59:56 +08:00
# Prefer
__fish_snap_subcommand prefer -r -d "Prefes aliases from a snap and disable conflicts"
__fish_snap_option prefer -a '(__fish_snap_installed_snaps)' -d Snap
2017-07-14 19:59:56 +08:00
# Refresh
__fish_snap_subcommand refresh -r -d "Refreshes a snap in the system"
__fish_snap_option refresh -l channel -d "Use this channel instead of stable"
__fish_snap_option refresh -l edge -d "Install from the edge channel"
__fish_snap_option refresh -l beta -d "Install from the beta channel"
__fish_snap_option refresh -l candidate -d "Install from the candidate channel"
__fish_snap_option refresh -l stable -d "Install from the stable channel"
__fish_snap_option refresh -l revision -d "Refresh to the given revision"
__fish_snap_option refresh -l devmode -d "Put snap in development mode and disable security confinement"
__fish_snap_option refresh -l jailmode -d "Put snap in enforced confinement mode"
__fish_snap_option refresh -l classic -d "Put snap in classic mode and disable security confinement"
__fish_snap_option refresh -l ignore-validation -d "Ignore validation by other snaps blocking the refresh"
__fish_snap_option refresh -a '(__fish_snap_installed_snaps)' -d Snap
2017-07-14 19:59:56 +08:00
# Remove
__fish_snap_subcommand remove -r -d "Removes a snap from the system"
__fish_snap_option remove -l revision -d "Removes only the given revision"
__fish_snap_option remove -a '(__fish_snap_installed_snaps)' -d Snap
2017-07-14 19:59:56 +08:00
# Revert
__fish_snap_subcommand revert -r -d "Revert the given snap to the previous state"
__fish_snap_option refresh -l revision -d "Revert to the given revision"
__fish_snap_option refresh -l devmode -d "Put snap in development mode and disable security confinement"
__fish_snap_option refresh -l jailmode -d "Put snap in enforced confinement mode"
__fish_snap_option refresh -l classic -d "Put snap in classic mode and disable security confinement"
__fish_snap_option revert -a '(__fish_snap_installed_snaps)' -d Snap
2017-07-14 19:59:56 +08:00
# Run
__fish_snap_subcommand run -r -d "Run the given snap command"
__fish_snap_option run -l shell -d "Run a shell instead of the command (useful for debugging)"
__fish_snap_option run -a '(__fish_snap_installed_snaps)' -d Snap
2017-07-14 19:59:56 +08:00
# There seems to be no programmatic way of getting configuration options
# Set
__fish_snap_subcommand set -r -d "Changes configuration options"
__fish_snap_option set -a '(__fish_snap_installed_snaps)' -d Snap
2017-07-14 19:59:56 +08:00
# Tasks
__fish_snap_subcommand tasks -d "List a change's tasks"
__fish_snap_option tasks -a '(__fish_snap_change_id)' -d ID
2017-07-14 19:59:56 +08:00
# Try
__fish_snap_subcommand try -r -d "Tests a snap in the system"
__fish_snap_option try -l devmode -d "Put snap in development mode and disable security confinement"
__fish_snap_option try -l jailmode -d "Put snap in enforced confinement mode"
__fish_snap_option try -l classic -d "Put snap in classic mode and disable security confinement"
2017-07-14 19:59:56 +08:00
# Unalias
__fish_snap_subcommand unalias -r -d "Unalias a manual alias or an entire snap"
__fish_snap_option unalias -a '(__fish_snap_aliases)' -d "Alias or snap"
2017-07-14 19:59:56 +08:00
# Version
__fish_snap_subcommand version -d "Shows version details"
2017-07-14 19:59:56 +08:00
# Watch
__fish_snap_subcommand watch -d "Watch a change in progress"
__fish_snap_option watch -a '(__fish_snap_change_id)' -d ID