File tree 2 files changed +40
-16
lines changed
2 files changed +40
-16
lines changed Original file line number Diff line number Diff line change 5
5
package cli
6
6
7
7
import (
8
- "os"
9
-
10
- log "github.com/scaleway/scaleway-cli/vendor/github.com/Sirupsen/logrus"
11
-
12
- "github.com/scaleway/scaleway-cli/pkg/utils"
8
+ "github.com/scaleway/scaleway-cli/pkg/commands"
9
+ "github.com/scaleway/scaleway-cli/vendor/github.com/Sirupsen/logrus"
13
10
)
14
11
15
12
var cmdLogout = & Command {
@@ -26,23 +23,18 @@ func init() {
26
23
// FLags
27
24
var logoutHelp bool // -h, --help flag
28
25
29
- func runLogout (cmd * Command , args []string ) {
26
+ func runLogout (cmd * Command , rawArgs []string ) {
30
27
if logoutHelp {
31
28
cmd .PrintUsage ()
32
29
}
33
- if len (args ) != 0 {
30
+ if len (rawArgs ) != 0 {
34
31
cmd .PrintShortUsage ()
35
32
}
36
33
37
- scwrcPath , err := utils .GetConfigFilePath ()
34
+ args := commands.LogoutArgs {}
35
+ ctx := cmd .GetContext (rawArgs )
36
+ err := commands .RunLogout (ctx , args )
38
37
if err != nil {
39
- log .Fatalf ("Unable to get scwrc config file path: %v" , err )
40
- }
41
-
42
- if _ , err = os .Stat (scwrcPath ); err == nil {
43
- err = os .Remove (scwrcPath )
44
- if err != nil {
45
- log .Fatalf ("Unable to remove scwrc config file: %v" , err )
46
- }
38
+ logrus .Fatalf ("Cannot execute 'logout': %v" , err )
47
39
}
48
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
+ "os"
10
+
11
+ "github.com/scaleway/scaleway-cli/pkg/utils"
12
+ )
13
+
14
+ // LogoutArgs are flags for the `RunLogout` function
15
+ type LogoutArgs struct {}
16
+
17
+ // RunLogout is the handler for 'scw logout'
18
+ func RunLogout (ctx CommandContext , args LogoutArgs ) error {
19
+ // FIXME: ask if we need to remove the local ssh key on the account
20
+ scwrcPath , err := utils .GetConfigFilePath ()
21
+ if err != nil {
22
+ return fmt .Errorf ("unable to get scwrc config file path: %v" , err )
23
+ }
24
+
25
+ if _ , err = os .Stat (scwrcPath ); err == nil {
26
+ err = os .Remove (scwrcPath )
27
+ if err != nil {
28
+ return fmt .Errorf ("unable to remove scwrc config file: %v" , err )
29
+ }
30
+ }
31
+ return nil
32
+ }
You can’t perform that action at this time.
0 commit comments