github.com/scaleway/scaleway-cli@v1.11.1/pkg/cli/cmd_inspect.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 cmdInspect = &Command{ 10 Exec: runInspect, 11 UsageLine: "inspect [OPTIONS] IDENTIFIER [IDENTIFIER...]", 12 Description: "Return low-level information on a server, image, snapshot, volume or bootscript", 13 Help: "Return low-level information on a server, image, snapshot, volume or bootscript.", 14 Examples: ` 15 $ scw inspect my-server 16 $ scw inspect server:my-server 17 $ scw inspect --browser my-server 18 $ scw inspect a-public-image 19 $ scw inspect image:a-public-image 20 $ scw inspect my-snapshot 21 $ scw inspect snapshot:my-snapshot 22 $ scw inspect my-volume 23 $ scw inspect volume:my-volume 24 $ scw inspect my-image 25 $ scw inspect image:my-image 26 $ scw inspect my-server | jq '.[0].public_ip.address' 27 $ scw inspect $(scw inspect my-image | jq '.[0].root_volume.id') 28 $ scw inspect -f "{{ .PublicAddress.IP }}" my-server 29 $ scw --sensitive inspect my-server 30 `, 31 } 32 33 func init() { 34 cmdInspect.Flag.BoolVar(&inspectHelp, []string{"h", "-help"}, false, "Print usage") 35 cmdInspect.Flag.StringVar(&inspectFormat, []string{"f", "-format"}, "", "Format the output using the given go template") 36 cmdInspect.Flag.BoolVar(&inspectBrowser, []string{"b", "-browser"}, false, "Inspect object in browser") 37 cmdInspect.Flag.StringVar(&inspectArch, []string{"-arch"}, "*", "Specify architecture") 38 } 39 40 // Flags 41 var inspectFormat string // -f, --format flag 42 var inspectBrowser bool // -b, --browser flag 43 var inspectHelp bool // -h, --help flag 44 var inspectArch string // --arch flag 45 46 func runInspect(cmd *Command, rawArgs []string) error { 47 if inspectHelp { 48 return cmd.PrintUsage() 49 } 50 if len(rawArgs) < 1 { 51 return cmd.PrintShortUsage() 52 } 53 54 args := commands.InspectArgs{ 55 Format: inspectFormat, 56 Browser: inspectBrowser, 57 Identifiers: rawArgs, 58 Arch: inspectArch, 59 } 60 ctx := cmd.GetContext(rawArgs) 61 return commands.RunInspect(ctx, args) 62 }