Skip to content

Commit

Permalink
cmd/snap: rename revoke to disconnect
Browse files Browse the repository at this point in the history
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
  • Loading branch information
zyga committed Feb 24, 2016
1 parent ff28117 commit 89dfd81
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 38 deletions.
34 changes: 17 additions & 17 deletions cmd/snap/cmd_revoke.go → cmd/snap/cmd_disconnect.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,40 @@ import (
"github.com/ubuntu-core/snappy/i18n"
)

type cmdRevoke struct {
type cmdDisconnect struct {
Positionals struct {
Offer SnapAndName `positional-arg-name:"<snap>:<skill>" required:"true"`
Use SnapAndName `positional-arg-name:"<snap>:<skill slot>"`
Offer SnapAndName `positional-arg-name:"<snap>:<plug>" required:"true"`
Use SnapAndName `positional-arg-name:"<snap>:<slot>"`
} `positional-args:"true"`
}

var shortRevokeHelp = i18n.G("Revokes a skill granted to a skill slot")
var longRevokeHelp = i18n.G(`
The revoke command unassigns previously granted skills from a snap.
var shortDisconnectHelp = i18n.G("Disconnects a plug from a slot")
var longDisconnectHelp = i18n.G(`
The disconnect command disconnects a plug from a slot.
It may be called in the following ways:
$ snap revoke <snap>:<skill> <snap>:<skill slot>
$ snap disconnect <snap>:<plug> <snap>:<slot>
Revokes the specific skill from the specific skill slot.
Disconnects the specific plug from the specific slot.
$ snap revoke <snap>:<skill slot>
$ snap disconnect <snap>:<slot>
Revokes any previously granted skill from the provided skill slot.
Disconnects any previously connected plugs from the provided slot.
$ snap revoke <snap>
$ snap disconnect <snap>
Revokes all skills from the provided snap.
Disconnects all plugs from the provided snap.
`)

func init() {
addCommand("revoke", shortRevokeHelp, longRevokeHelp, func() interface{} {
return &cmdRevoke{}
addCommand("disconnect", shortDisconnectHelp, longDisconnectHelp, func() interface{} {
return &cmdDisconnect{}
})
}

func (x *cmdRevoke) Execute(args []string) error {
// snap revoke <snap>:<skill slot>
// snap revoke <snap>
func (x *cmdDisconnect) Execute(args []string) error {
// snap disconnect <snap>:<slot>
// snap disconnect <snap>
if x.Positionals.Use.Snap == "" && x.Positionals.Use.Name == "" {
// Swap Offer and Use around
x.Positionals.Offer, x.Positionals.Use = x.Positionals.Use, x.Positionals.Offer
Expand Down
42 changes: 21 additions & 21 deletions cmd/snap/cmd_revoke_test.go → cmd/snap/cmd_disconnect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,46 +28,46 @@ import (
. "github.com/ubuntu-core/snappy/cmd/snap"
)

func (s *SnapSuite) TestRevokeHelp(c *C) {
func (s *SnapSuite) TestDisconnectHelp(c *C) {
msg := `Usage:
snap.test [OPTIONS] revoke [<snap>:<skill>] [<snap>:<skill slot>]
snap.test [OPTIONS] disconnect [<snap>:<plug>] [<snap>:<slot>]
The revoke command unassigns previously granted skills from a snap.
The disconnect command disconnects a plug from a slot.
It may be called in the following ways:
$ snap revoke <snap>:<skill> <snap>:<skill slot>
$ snap disconnect <snap>:<plug> <snap>:<slot>
Revokes the specific skill from the specific skill slot.
Disconnects the specific plug from the specific slot.
$ snap revoke <snap>:<skill slot>
$ snap disconnect <snap>:<slot>
Revokes any previously granted skill from the provided skill slot.
Disconnects any previously connected plugs from the provided slot.
$ snap revoke <snap>
$ snap disconnect <snap>
Revokes all skills from the provided snap.
Disconnects all plugs from the provided snap.
Help Options:
-h, --help Show this help message
-h, --help Show this help message
[revoke command arguments]
<snap>:<skill>
<snap>:<skill slot>
[disconnect command arguments]
<snap>:<plug>
<snap>:<slot>
`
rest, err := Parser().ParseArgs([]string{"revoke", "--help"})
rest, err := Parser().ParseArgs([]string{"disconnect", "--help"})
c.Assert(err.Error(), Equals, msg)
c.Assert(rest, DeepEquals, []string{})
}

func (s *SnapSuite) TestRevokeExplicitEverything(c *C) {
func (s *SnapSuite) TestDisconnectExplicitEverything(c *C) {
s.RedirectClientToTestServer(func(w http.ResponseWriter, r *http.Request) {
c.Check(r.Method, Equals, "POST")
c.Check(r.URL.Path, Equals, "/2.0/skills")
c.Check(DecodedRequestBody(c, r), DeepEquals, map[string]interface{}{
"action": "revoke",
"skill": map[string]interface{}{
"snap": "producer",
"name": "skill",
"name": "plug",
},
"slot": map[string]interface{}{
"snap": "consumer",
Expand All @@ -76,14 +76,14 @@ func (s *SnapSuite) TestRevokeExplicitEverything(c *C) {
})
fmt.Fprintln(w, `{"type":"sync", "result":{}}`)
})
rest, err := Parser().ParseArgs([]string{"revoke", "producer:skill", "consumer:slot"})
rest, err := Parser().ParseArgs([]string{"disconnect", "producer:plug", "consumer:slot"})
c.Assert(err, IsNil)
c.Assert(rest, DeepEquals, []string{})
c.Assert(s.Stdout(), Equals, "")
c.Assert(s.Stderr(), Equals, "")
}

func (s *SnapSuite) TestRevokeEverythingFromSpecificSlot(c *C) {
func (s *SnapSuite) TestDisconnectEverythingFromSpecificSlot(c *C) {
s.RedirectClientToTestServer(func(w http.ResponseWriter, r *http.Request) {
c.Check(r.Method, Equals, "POST")
c.Check(r.URL.Path, Equals, "/2.0/skills")
Expand All @@ -100,14 +100,14 @@ func (s *SnapSuite) TestRevokeEverythingFromSpecificSlot(c *C) {
})
fmt.Fprintln(w, `{"type":"sync", "result":{}}`)
})
rest, err := Parser().ParseArgs([]string{"revoke", "consumer:slot"})
rest, err := Parser().ParseArgs([]string{"disconnect", "consumer:slot"})
c.Assert(err, IsNil)
c.Assert(rest, DeepEquals, []string{})
c.Assert(s.Stdout(), Equals, "")
c.Assert(s.Stderr(), Equals, "")
}

func (s *SnapSuite) TestRevokeEverythingFromSpecificSnap(c *C) {
func (s *SnapSuite) TestDisconnectEverythingFromSpecificSnap(c *C) {
s.RedirectClientToTestServer(func(w http.ResponseWriter, r *http.Request) {
c.Check(r.Method, Equals, "POST")
c.Check(r.URL.Path, Equals, "/2.0/skills")
Expand All @@ -124,7 +124,7 @@ func (s *SnapSuite) TestRevokeEverythingFromSpecificSnap(c *C) {
})
fmt.Fprintln(w, `{"type":"sync", "result":{}}`)
})
rest, err := Parser().ParseArgs([]string{"revoke", "consumer"})
rest, err := Parser().ParseArgs([]string{"disconnect", "consumer"})
c.Assert(err, IsNil)
c.Assert(rest, DeepEquals, []string{})
c.Assert(s.Stdout(), Equals, "")
Expand Down

0 comments on commit 89dfd81

Please sign in to comment.