1
// Copyright 2012, 2013 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
9
"launchpad.net/gnuflag"
11
"launchpad.net/juju-core/charm"
12
"launchpad.net/juju-core/cmd"
13
"launchpad.net/juju-core/store"
16
type DeleteCharmCommand struct {
21
func (c *DeleteCharmCommand) Info() *cmd.Info {
24
Purpose: "delete a published charm from the charm store",
28
func (c *DeleteCharmCommand) SetFlags(f *gnuflag.FlagSet) {
29
c.ConfigCommand.SetFlags(f)
30
f.StringVar(&c.Url, "url", "", "charm URL")
33
func (c *DeleteCharmCommand) Init(args []string) error {
35
err := c.ConfigCommand.Init(args)
40
return fmt.Errorf("--url is required")
45
func (c *DeleteCharmCommand) Run(ctx *cmd.Context) error {
47
err := c.ConfigCommand.ReadConfig(ctx)
52
// Parse the charm URL
53
charmUrl, err := charm.ParseURL(c.Url)
58
// Open the charm store storage
59
s, err := store.Open(c.Config.MongoURL)
65
// Delete the charm by URL
66
_, err = s.DeleteCharm(charmUrl)
70
fmt.Fprintln(ctx.Stdout, "Charm", charmUrl, "deleted.")
74
func (c *DeleteCharmCommand) AllowInterspersedFlags() bool {