Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit c73bde7

Browse files
Use positional arguments for unloading plugins
This change is to simplify and normalize the unload command for Snap 1.0
1 parent c644599 commit c73bde7

2 files changed

Lines changed: 7 additions & 22 deletions

File tree

cmd/snapctl/commands.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,8 @@ var (
108108
},
109109
{
110110
Name: "unload",
111-
Usage: "unload <plugin_type>:<plugin_name>:<plugin_version> or unload -t <plugin_type> -n <plugin_name> -v <plugin_version>",
111+
Usage: "unload <plugin_type> <plugin_name> <plugin_version>",
112112
Action: unloadPlugin,
113-
Flags: []cli.Flag{
114-
flPluginType,
115-
flPluginName,
116-
flPluginVersion,
117-
},
118113
},
119114
{
120115
Name: "swap",

cmd/snapctl/plugin.go

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,29 +64,19 @@ func loadPlugin(ctx *cli.Context) error {
6464
}
6565

6666
func unloadPlugin(ctx *cli.Context) error {
67-
pDetails := filepath.SplitList(ctx.Args().First())
68-
var pType, pName string
69-
var pVer int
70-
var err error
67+
pType := ctx.Args().Get(0)
68+
pName := ctx.Args().Get(1)
69+
pVer, err := strconv.Atoi(ctx.Args().Get(2))
7170

72-
if len(pDetails) == 3 {
73-
pType = pDetails[0]
74-
pName = pDetails[1]
75-
pVer, err = strconv.Atoi(pDetails[2])
76-
if err != nil {
77-
return newUsageError("Can't convert version string to integer", ctx)
78-
}
79-
} else {
80-
pType = ctx.String("plugin-type")
81-
pName = ctx.String("plugin-name")
82-
pVer = ctx.Int("plugin-version")
83-
}
8471
if pType == "" {
8572
return newUsageError("Must provide plugin type", ctx)
8673
}
8774
if pName == "" {
8875
return newUsageError("Must provide plugin name", ctx)
8976
}
77+
if err != nil {
78+
return newUsageError("Can't convert version string to integer", ctx)
79+
}
9080
if pVer < 1 {
9181
return newUsageError("Must provide plugin version", ctx)
9282
}

0 commit comments

Comments
 (0)