|
| 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 commands |
| 6 | + |
| 7 | +import ( |
| 8 | + "fmt" |
| 9 | + "os" |
| 10 | + "runtime" |
| 11 | + |
| 12 | + "github.com/scaleway/scaleway-cli/vendor/github.com/kardianos/osext" |
| 13 | + |
| 14 | + "github.com/scaleway/scaleway-cli/pkg/utils" |
| 15 | +) |
| 16 | + |
| 17 | +// InfoArgs are flags for the `RunInfo` function |
| 18 | +type InfoArgs struct{} |
| 19 | + |
| 20 | +// RunInfo is the handler for 'scw info' |
| 21 | +func RunInfo(ctx CommandContext, args InfoArgs) error { |
| 22 | + // FIXME: fmt.Fprintf(ctx.Stdout, "Servers: %s\n", "quantity") |
| 23 | + // FIXME: fmt.Fprintf(ctx.Stdout, "Images: %s\n", "quantity") |
| 24 | + fmt.Fprintf(ctx.Stdout, "Debug mode (client): %v\n", ctx.Getenv("DEBUG") != "") |
| 25 | + |
| 26 | + fmt.Fprintf(ctx.Stdout, "Organization: %s\n", ctx.API.Organization) |
| 27 | + // FIXME: add partially-masked token |
| 28 | + fmt.Fprintf(ctx.Stdout, "API Endpoint: %s\n", ctx.Getenv("scaleway_api_endpoint")) |
| 29 | + configPath, _ := utils.GetConfigFilePath() |
| 30 | + fmt.Fprintf(ctx.Stdout, "RC file: %s\n", configPath) |
| 31 | + fmt.Fprintf(ctx.Stdout, "User: %s\n", ctx.Getenv("USER")) |
| 32 | + fmt.Fprintf(ctx.Stdout, "CPUs: %d\n", runtime.NumCPU()) |
| 33 | + hostname, _ := os.Hostname() |
| 34 | + fmt.Fprintf(ctx.Stdout, "Hostname: %s\n", hostname) |
| 35 | + cliPath, _ := osext.Executable() |
| 36 | + fmt.Fprintf(ctx.Stdout, "CLI Path: %s\n", cliPath) |
| 37 | + |
| 38 | + fmt.Fprintf(ctx.Stdout, "Cache: %s\n", ctx.API.Cache.Path) |
| 39 | + fmt.Fprintf(ctx.Stdout, " Servers: %d\n", ctx.API.Cache.GetNbServers()) |
| 40 | + fmt.Fprintf(ctx.Stdout, " Images: %d\n", ctx.API.Cache.GetNbImages()) |
| 41 | + fmt.Fprintf(ctx.Stdout, " Snapshots: %d\n", ctx.API.Cache.GetNbSnapshots()) |
| 42 | + fmt.Fprintf(ctx.Stdout, " Volumes: %d\n", ctx.API.Cache.GetNbVolumes()) |
| 43 | + fmt.Fprintf(ctx.Stdout, " Bootscripts: %d\n", ctx.API.Cache.GetNbBootscripts()) |
| 44 | + return nil |
| 45 | +} |
0 commit comments