github.com/scaleway/scaleway-cli@v1.11.1/pkg/cli/cmd_history.go (about) 1 // Copyright (C) 2015 Scaleway. All rights reserved. 2 // Use of this source code is governed by a MIT-style 3 // license that can be found in the LICENSE.md file. 4 5 package cli 6 7 import "github.com/scaleway/scaleway-cli/pkg/commands" 8 9 var cmdHistory = &Command{ 10 Exec: runHistory, 11 UsageLine: "history [OPTIONS] IMAGE", 12 Description: "Show the history of an image", 13 Help: "Show the history of an image.", 14 } 15 16 func init() { 17 cmdHistory.Flag.BoolVar(&historyNoTrunc, []string{"-no-trunc"}, false, "Don't truncate output") 18 cmdHistory.Flag.BoolVar(&historyQuiet, []string{"q", "-quiet"}, false, "Only show numeric IDs") 19 cmdHistory.Flag.BoolVar(&historyHelp, []string{"h", "-help"}, false, "Print usage") 20 cmdHistory.Flag.StringVar(&historyArch, []string{"-arch"}, "*", "Specify architecture") 21 } 22 23 // Flags 24 var historyNoTrunc bool // --no-trunc flag 25 var historyQuiet bool // -q, --quiet flag 26 var historyHelp bool // -h, --help flag 27 var historyArch string // --arch flag 28 29 func runHistory(cmd *Command, rawArgs []string) error { 30 if historyHelp { 31 return cmd.PrintUsage() 32 } 33 if len(rawArgs) != 1 { 34 return cmd.PrintShortUsage() 35 } 36 37 args := commands.HistoryArgs{ 38 Quiet: historyQuiet, 39 NoTrunc: historyNoTrunc, 40 Image: rawArgs[0], 41 Arch: historyArch, 42 } 43 ctx := cmd.GetContext(rawArgs) 44 return commands.RunHistory(ctx, args) 45 }