-
Notifications
You must be signed in to change notification settings - Fork 0
/
stash.go
60 lines (51 loc) · 1.36 KB
/
stash.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright 2019 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package main
import (
"os"
"github.com/juju/cmd"
"github.com/juju/utils/featureflag"
"github.com/juju/juju/juju"
"github.com/juju/juju/juju/osenv"
"github.com/juju/juju/jujuclient"
)
var stashDoc = `
Juju stash is used to move between models without having to specify model names
`
func Main(args []string) {
ctx, err := cmd.DefaultContext()
if err != nil {
cmd.WriteError(os.Stderr, err)
os.Exit(2)
}
if err := juju.InitJujuXDGDataHome(); err != nil {
cmd.WriteError(ctx.Stderr, err)
os.Exit(2)
}
os.Exit(cmd.Main(NewSuperCommand(ctx), ctx, args[1:]))
}
func NewSuperCommand(ctx *cmd.Context) cmd.Command {
stashcmd := cmd.NewSuperCommand(cmd.SuperCommandParams{
Name: "stash",
UsagePrefix: "juju",
Doc: stashDoc,
Purpose: "cmd line tool for moving easily between models",
Log: &cmd.Log{},
})
history, err := newHistory()
if err != nil {
cmd.WriteError(ctx.Stderr, err)
os.Exit(2)
}
clientStore := jujuclient.NewFileClientStore()
stashcmd.Register(newPushCommand(clientStore, history))
stashcmd.Register(newPopCommand(clientStore, history))
stashcmd.Register(newListCommand(history))
return stashcmd
}
func init() {
featureflag.SetFlagsFromEnvironment(osenv.JujuFeatureFlagEnvKey)
}
func main() {
Main(os.Args)
}