Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request intelsdi-x#1235 from kindermoumoute/unload_arguments
Browse files Browse the repository at this point in the history
Use positional arguments for unloading plugins
  • Loading branch information
candysmurf authored Sep 28, 2016
2 parents 8fd4664 + c73bde7 commit e9d9821
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 e9d9821

Please sign in to comment.