/
cmd_history.go
45 lines (38 loc) · 1.32 KB
/
cmd_history.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
// Copyright (C) 2015 Scaleway. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE.md file.
package cli
import "github.com/scaleway/scaleway-cli/pkg/commands"
var cmdHistory = &Command{
Exec: runHistory,
UsageLine: "history [OPTIONS] IMAGE",
Description: "Show the history of an image",
Help: "Show the history of an image.",
}
func init() {
cmdHistory.Flag.BoolVar(&historyNoTrunc, []string{"-no-trunc"}, false, "Don't truncate output")
cmdHistory.Flag.BoolVar(&historyQuiet, []string{"q", "-quiet"}, false, "Only show numeric IDs")
cmdHistory.Flag.BoolVar(&historyHelp, []string{"h", "-help"}, false, "Print usage")
cmdHistory.Flag.StringVar(&historyArch, []string{"-arch"}, "*", "Specify architecture")
}
// Flags
var historyNoTrunc bool // --no-trunc flag
var historyQuiet bool // -q, --quiet flag
var historyHelp bool // -h, --help flag
var historyArch string // --arch flag
func runHistory(cmd *Command, rawArgs []string) error {
if historyHelp {
return cmd.PrintUsage()
}
if len(rawArgs) != 1 {
return cmd.PrintShortUsage()
}
args := commands.HistoryArgs{
Quiet: historyQuiet,
NoTrunc: historyNoTrunc,
Image: rawArgs[0],
Arch: historyArch,
}
ctx := cmd.GetContext(rawArgs)
return commands.RunHistory(ctx, args)
}