From 9350770c33aabffbba9d13dd0cb5eb08703f7e30 Mon Sep 17 00:00:00 2001 From: Dan Walsh Date: Sat, 17 Sep 2016 05:44:25 -0400 Subject: [PATCH] Fix up atomic trust completions Closes: #627 Approved by: rhatdan --- Atomic/trust.py | 6 +-- bash/atomic | 107 +++++++++++++++++++++++++++++++++++++----------- 2 files changed, 86 insertions(+), 27 deletions(-) diff --git a/Atomic/trust.py b/Atomic/trust.py index 7a91333..69f5c45 100644 --- a/Atomic/trust.py +++ b/Atomic/trust.py @@ -30,10 +30,10 @@ def cli(subparser): "File(s) must exist before using this command. " "Default directory is %s" % pubkeys_dir)) commonp.add_argument("--sigstoretype", dest="sigstoretype", default="web", - choices=['local', 'web', 'atomic'], + choices=['atomic', 'local', 'web'], help=sigstore_help) commonp.add_argument("-t", "--type", dest="trust_type", default="signedBy", - choices=['signedBy', 'insecureAcceptAnything', 'reject'], + choices=['insecureAcceptAnything', 'reject', 'signedBy'], help="Trust type (default: signedBy)") commonp.add_argument("--keytype", dest="keytype", default="GPGKeys", help="Public key type (default: GPGKeys)") @@ -57,7 +57,7 @@ def cli(subparser): deletep.add_argument("registry", help=registry_help) deletep.add_argument("--sigstoretype", dest="sigstoretype", default="web", - choices=['local', 'web', 'atomic'], + choices=['atomic', 'local', 'web'], help=sigstore_help) deletep.set_defaults(_class=Trust, func="delete") diff --git a/bash/atomic b/bash/atomic index fa81c88..3708349 100644 --- a/bash/atomic +++ b/bash/atomic @@ -397,14 +397,14 @@ _atomic_containers_list() { _atomic_containers_trim() { local all_options=" - --help - " + --help + " case "$cur" in - -*) - COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) ) - ;; - esac + -*) + COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) ) + ;; + esac } _atomic_update() { @@ -674,29 +674,88 @@ _atomic_trust() { return 0 } +_atomic_trust_default() { + local subcommands=" + accept + reject + " + local all_options="$options_with_args + --help -h + " + + local options_with_args_glob=$(__atomic_to_extglob "$options_with_args") + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) ) + ;; + *) + COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) + ;; + esac +} _atomic_trust_add() { local options_with_args=" - --pubkeys -k - --sigstoretype - --type -t - --keytype - --sigstore -s + --pubkeys -k + --sigstoretype + --type -t + --keytype + --sigstore -s + " + local all_options="$options_with_args + --help -h " - local all_options="$options_with_args - --help -h - " - local options_with_args_glob=$(__atomic_to_extglob "$options_with_args") + local options_with_args_glob=$(__atomic_to_extglob "$options_with_args") - case "$cur" in - -*) - COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) ) - ;; - *) - local counter=$( __atomic_pos_first_nonflag $( __atomic_to_alternatives "$options_with_args" ) ) - ;; + case "$prev" in + --keytype) + COMPREPLY=( $( compgen -W "GPGKeys" -- "$cur" ) ) + ;; + --sigstoretype) + COMPREPLY=( $( compgen -W "atomic local web" -- "$cur" ) ) + ;; + --type|-t) + COMPREPLY=( $( compgen -W "signedBy insecureAcceptAnything reject" -- "$cur" ) ) + ;; + esac - esac + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) ) + ;; + *) + local counter=$( __atomic_pos_first_nonflag $( __atomic_to_alternatives "$options_with_args" ) ) + ;; + + esac +} + +_atomic_trust_delete() { + local options_with_args=" + --sigstoretype + " + local all_options="$options_with_args + --help -h + " + + local options_with_args_glob=$(__atomic_to_extglob "$options_with_args") + + case "$prev" in + --sigstoretype) + COMPREPLY=( $( compgen -W "atomic local web" -- "$cur" ) ) + ;; + esac + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) ) + ;; + *) + local counter=$( __atomic_pos_first_nonflag $( __atomic_to_alternatives "$options_with_args" ) ) + ;; + + esac } _atomic_mount() { @@ -1151,7 +1210,7 @@ _atomic() { sign stop top - trust + trust verify version uninstall