-
Notifications
You must be signed in to change notification settings - Fork 491
/
action-log.go
44 lines (35 loc) · 936 Bytes
/
action-log.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
// Copyright 2019 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package jujuc
import (
"strings"
"github.com/juju/cmd/v3"
"github.com/juju/errors"
jujucmd "github.com/juju/juju/cmd"
)
// ActionLogCommand implements the action-log command.
type ActionLogCommand struct {
cmd.CommandBase
ctx Context
Message string
}
func NewActionLogCommand(ctx Context) (cmd.Command, error) {
return &ActionLogCommand{ctx: ctx}, nil
}
func (c *ActionLogCommand) Info() *cmd.Info {
return jujucmd.Info(&cmd.Info{
Name: "action-log",
Args: "<message>",
Purpose: "record a progress message for the current action",
})
}
func (c *ActionLogCommand) Init(args []string) error {
if args == nil {
return errors.New("no message specified")
}
c.Message = strings.Join(args, " ")
return nil
}
func (c *ActionLogCommand) Run(ctx *cmd.Context) error {
return c.ctx.LogActionMessage(c.Message)
}