Skip to content

Commit 617094f

Browse files
committed
gofmt
1 parent d865b28 commit 617094f

10 files changed

+33
-26
lines changed

cmd/nc.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import (
44
"fmt"
55
"net"
66

7-
"github.com/naiba/nb/singleton"
87
"github.com/urfave/cli/v2"
8+
9+
"github.com/naiba/nb/singleton"
910
)
1011

1112
func init() {

cmd/print_banner.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import (
55
"os"
66

77
"github.com/dimiro1/banner"
8+
"github.com/urfave/cli/v2"
9+
810
"github.com/naiba/nb/assets"
911
"github.com/naiba/nb/singleton"
10-
"github.com/urfave/cli/v2"
1112
)
1213

1314
func init() {

cmd/print_config.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ package cmd
33
import (
44
"fmt"
55

6-
"github.com/naiba/nb/singleton"
76
"github.com/urfave/cli/v2"
7+
8+
"github.com/naiba/nb/singleton"
89
)
910

1011
func init() {

cmd/print_snippet.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import (
44
"fmt"
55
"os"
66

7-
"github.com/naiba/nb/singleton"
87
"github.com/urfave/cli/v2"
8+
9+
"github.com/naiba/nb/singleton"
910
)
1011

1112
func init() {

cmd/root.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import (
55
"net"
66
"os"
77

8-
"github.com/naiba/nb/singleton"
9-
108
"github.com/urfave/cli/v2"
9+
10+
"github.com/naiba/nb/singleton"
1111
)
1212

1313
var rootCmd = &cli.App{

cmd/rsync.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import (
44
"fmt"
55
"net"
66

7-
"github.com/naiba/nb/singleton"
87
"github.com/urfave/cli/v2"
8+
9+
"github.com/naiba/nb/singleton"
910
)
1011

1112
func init() {

cmd/run.go

+16-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package cmd
22

33
import (
4+
"os"
45
"runtime"
56
"strings"
67

78
"github.com/AppleGamer22/cocainate/session"
8-
99
"github.com/urfave/cli/v2"
1010
)
1111

@@ -45,22 +45,24 @@ var beepCmd = &cli.Command{
4545
},
4646
}
4747

48-
var s session.Session
48+
var s *session.Session
4949

5050
var awakeCmd = &cli.Command{
5151
Name: "awake",
5252
Aliases: []string{"a"},
5353
Usage: "Awake during the command is running.",
5454
SkipFlagParsing: true,
5555
Before: func(c *cli.Context) error {
56-
s = session.Session{}
56+
s = session.New(0, os.Getppid())
5757
return s.Start()
5858
},
5959
Action: func(c *cli.Context) error {
60-
return ExecuteLineInHost(strings.Join(c.Args().Slice(), " "))
61-
},
62-
After: func(c *cli.Context) error {
63-
return s.Stop()
60+
retCmd := ExecuteLineInHost(strings.Join(c.Args().Slice(), " "))
61+
retSession := s.Stop()
62+
if retCmd != nil {
63+
return retCmd
64+
}
65+
return retSession
6466
},
6567
}
6668

@@ -70,13 +72,15 @@ var awakeBeepCmd = &cli.Command{
7072
Usage: "Awake and beep when an command is finished.",
7173
SkipFlagParsing: true,
7274
Before: func(c *cli.Context) error {
73-
s = session.Session{}
75+
s = session.New(0, os.Getppid())
7476
return s.Start()
7577
},
7678
Action: func(c *cli.Context) error {
77-
return beepCmd.Action(c)
78-
},
79-
After: func(c *cli.Context) error {
80-
return s.Stop()
79+
retCmd := beepCmd.Action(c)
80+
retSession := s.Stop()
81+
if retCmd != nil {
82+
return retCmd
83+
}
84+
return retSession
8185
},
8286
}

cmd/scp.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import (
44
"fmt"
55
"net"
66

7-
"github.com/naiba/nb/singleton"
87
"github.com/urfave/cli/v2"
8+
9+
"github.com/naiba/nb/singleton"
910
)
1011

1112
func init() {

cmd/ssh.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ import (
77
"strings"
88
"sync"
99

10-
"github.com/naiba/nb/model"
11-
"github.com/naiba/nb/singleton"
1210
"github.com/urfave/cli/v2"
1311
"golang.org/x/crypto/ssh"
12+
13+
"github.com/naiba/nb/model"
14+
"github.com/naiba/nb/singleton"
1415
)
1516

1617
func init() {

singleton/singleton.go

-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ import (
66

77
var Config *model.Config
88

9-
func init() {
10-
11-
}
12-
139
func Init(confPath string) error {
1410
var err error
1511
Config, err = model.ReadInConfig(confPath)

0 commit comments

Comments
 (0)