File tree 2 files changed +36
-11
lines changed
2 files changed +36
-11
lines changed Original file line number Diff line number Diff line change 5
5
package cli
6
6
7
7
import (
8
- "fmt"
9
- "runtime"
10
-
11
- "github.com/scaleway/scaleway-cli/pkg/scwversion"
8
+ "github.com/scaleway/scaleway-cli/pkg/commands"
9
+ "github.com/scaleway/scaleway-cli/vendor/github.com/Sirupsen/logrus"
12
10
)
13
11
14
12
var cmdVersion = & Command {
@@ -25,17 +23,18 @@ func init() {
25
23
// Flags
26
24
var versionHelp bool // -h, --help flag
27
25
28
- func runVersion (cmd * Command , args []string ) {
26
+ func runVersion (cmd * Command , rawArgs []string ) {
29
27
if versionHelp {
30
28
cmd .PrintUsage ()
31
29
}
32
- if len (args ) != 0 {
30
+ if len (rawArgs ) != 0 {
33
31
cmd .PrintShortUsage ()
34
32
}
35
33
36
- fmt .Printf ("Client version: %s\n " , scwversion .VERSION )
37
- fmt .Printf ("Go version (client): %s\n " , runtime .Version ())
38
- fmt .Printf ("Git commit (client): %s\n " , scwversion .GITCOMMIT )
39
- fmt .Printf ("OS/Arch (client): %s/%s\n " , runtime .GOOS , runtime .GOARCH )
40
- // FIXME: API version information
34
+ args := commands.VersionArgs {}
35
+ ctx := cmd .GetContext (rawArgs )
36
+ err := commands .RunVersion (ctx , args )
37
+ if err != nil {
38
+ logrus .Fatalf ("Cannot execute 'version': %v" , err )
39
+ }
41
40
}
Original file line number Diff line number Diff line change
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
+ "runtime"
10
+
11
+ "github.com/scaleway/scaleway-cli/pkg/scwversion"
12
+ )
13
+
14
+ // VersionArgs are flags for the `RunVersion` function
15
+ type VersionArgs struct {}
16
+
17
+ // RunVersion is the handler for 'scw version'
18
+ func RunVersion (ctx CommandContext , args VersionArgs ) error {
19
+ fmt .Fprintf (ctx .Stdout , "Client version: %s\n " , scwversion .VERSION )
20
+ fmt .Fprintf (ctx .Stdout , "Go version (client): %s\n " , runtime .Version ())
21
+ fmt .Fprintf (ctx .Stdout , "Git commit (client): %s\n " , scwversion .GITCOMMIT )
22
+ fmt .Fprintf (ctx .Stdout , "OS/Arch (client): %s/%s\n " , runtime .GOOS , runtime .GOARCH )
23
+ // FIXME: API version information
24
+
25
+ return nil
26
+ }
You can’t perform that action at this time.
0 commit comments