Permalink
Newer
100644
150 lines (131 sloc)
3.79 KB
18
)
19
20
// dummyHookContext implements jujuc.Context,
21
// as expected by jujuc.NewCommand.
24
func (dummyHookContext) AddMetrics(_, _ string, _ time.Time) error {
25
return nil
26
}
30
func (dummyHookContext) PublicAddress() (string, error) {
31
return "", errors.NotFoundf("PublicAddress")
33
func (dummyHookContext) PrivateAddress() (string, error) {
34
return "", errors.NotFoundf("PrivateAddress")
36
func (dummyHookContext) AvailabilityZone() (string, error) {
37
return "", errors.NotFoundf("AvailabilityZone")
51
func (dummyHookContext) HookRelation() (jujuc.ContextRelation, error) {
52
return nil, errors.NotFoundf("HookRelation")
54
func (dummyHookContext) RemoteUnitName() (string, error) {
55
return "", errors.NotFoundf("RemoteUnitName")
57
func (dummyHookContext) Relation(id int) (jujuc.ContextRelation, error) {
58
return nil, errors.NotFoundf("Relation")
60
func (dummyHookContext) RelationIds() ([]int, error) {
61
return []int{}, errors.NotFoundf("RelationIds")
64
func (dummyHookContext) RequestReboot(prio jujuc.RebootPriority) error {
65
return nil
66
}
67
68
func (dummyHookContext) HookStorageInstance() (*storage.StorageInstance, error) {
69
return nil, errors.NotFoundf("HookStorageInstance")
72
func (dummyHookContext) HookStorage() (jujuc.ContextStorageAttachment, error) {
73
return nil, errors.NotFoundf("HookStorage")
76
func (dummyHookContext) StorageInstance(id string) (*storage.StorageInstance, error) {
77
return nil, errors.NotFoundf("StorageInstance")
80
func (dummyHookContext) UnitStatus() (*jujuc.StatusInfo, error) {
81
return &jujuc.StatusInfo{}, nil
82
}
83
88
func (dummyHookContext) Component(name string) (jujuc.ContextComponent, error) {
89
return nil, nil
90
}
91
92
func newHelpToolCommand() cmd.Command {
93
return &helpToolCommand{}
94
}
95
96
type helpToolCommand struct {
110
tool, err := cmd.ZeroOrOneArgs(args)
111
if err == nil {
112
t.tool = tool
113
}
114
return err
115
}
116
118
var hookctx dummyHookContext
119
if c.tool == "" {
120
// Ripped from SuperCommand. We could Run() a SuperCommand
121
// with "help commands", but then the implicit "help" command
122
// shows up.
123
names := jujuc.CommandNames()
127
if c, err := jujuc.NewCommand(hookctx, name); err == nil {
128
if len(name) > longest {
129
longest = len(name)
130
}
134
for _, c := range cmds {
135
info := c.Info()
136
fmt.Fprintf(ctx.Stdout, "%-*s %s\n", longest, info.Name, info.Purpose)