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

Commit

Permalink
Use positional arguments for unloading plugins
Browse files Browse the repository at this point in the history
This change is to simplify and normalize the unload command for Snap 1.0
  • Loading branch information
kindermoumoute committed Sep 23, 2016
1 parent c644599 commit c73bde7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 22 deletions.
7 changes: 1 addition & 6 deletions cmd/snapctl/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,8 @@ var (
},
{
Name: "unload",
Usage: "unload <plugin_type>:<plugin_name>:<plugin_version> or unload -t <plugin_type> -n <plugin_name> -v <plugin_version>",
Usage: "unload <plugin_type> <plugin_name> <plugin_version>",
Action: unloadPlugin,
Flags: []cli.Flag{
flPluginType,
flPluginName,
flPluginVersion,
},
},
{
Name: "swap",
Expand Down
22 changes: 6 additions & 16 deletions cmd/snapctl/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,29 +64,19 @@ func loadPlugin(ctx *cli.Context) error {
}

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

if len(pDetails) == 3 {
pType = pDetails[0]
pName = pDetails[1]
pVer, err = strconv.Atoi(pDetails[2])
if err != nil {
return newUsageError("Can't convert version string to integer", ctx)
}
} else {
pType = ctx.String("plugin-type")
pName = ctx.String("plugin-name")
pVer = ctx.Int("plugin-version")
}
if pType == "" {
return newUsageError("Must provide plugin type", ctx)
}
if pName == "" {
return newUsageError("Must provide plugin name", ctx)
}
if err != nil {
return newUsageError("Can't convert version string to integer", ctx)
}
if pVer < 1 {
return newUsageError("Must provide plugin version", ctx)
}
Expand Down

0 comments on commit c73bde7

Please sign in to comment.