github.com/kubiko/snapd@v0.0.0-20201013125620-d4f3094d9ddf/cmd/snap/cmd_unalias.go (about) 1 // -*- Mode: Go; indent-tabs-mode: t -*- 2 3 /* 4 * Copyright (C) 2016 Canonical Ltd 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 3 as 8 * published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 20 package main 21 22 import ( 23 "github.com/snapcore/snapd/i18n" 24 25 "github.com/jessevdk/go-flags" 26 ) 27 28 type cmdUnalias struct { 29 waitMixin 30 Positionals struct { 31 AliasOrSnap aliasOrSnap `required:"yes"` 32 } `positional-args:"true"` 33 } 34 35 var shortUnaliasHelp = i18n.G("Remove a manual alias, or the aliases for an entire snap") 36 var longUnaliasHelp = i18n.G(` 37 The unalias command removes a single alias if the provided argument is a manual 38 alias, or disables all aliases of a snap, including manual ones, if the 39 argument is a snap name. 40 `) 41 42 func init() { 43 addCommand("unalias", shortUnaliasHelp, longUnaliasHelp, func() flags.Commander { 44 return &cmdUnalias{} 45 }, waitDescs.also(nil), []argDesc{ 46 // TRANSLATORS: This needs to begin with < and end with > 47 {name: i18n.G("<alias-or-snap>")}, 48 }) 49 } 50 51 func (x *cmdUnalias) Execute(args []string) error { 52 if len(args) > 0 { 53 return ErrExtraArgs 54 } 55 56 id, err := x.client.Unalias(string(x.Positionals.AliasOrSnap)) 57 if err != nil { 58 return err 59 } 60 chg, err := x.wait(id) 61 if err != nil { 62 if err == noWait { 63 return nil 64 } 65 return err 66 } 67 68 return showAliasChanges(chg) 69 }