File tree 10 files changed +33
-26
lines changed
10 files changed +33
-26
lines changed Original file line number Diff line number Diff line change 4
4
"fmt"
5
5
"net"
6
6
7
- "github.com/naiba/nb/singleton"
8
7
"github.com/urfave/cli/v2"
8
+
9
+ "github.com/naiba/nb/singleton"
9
10
)
10
11
11
12
func init () {
Original file line number Diff line number Diff line change @@ -5,9 +5,10 @@ import (
5
5
"os"
6
6
7
7
"github.com/dimiro1/banner"
8
+ "github.com/urfave/cli/v2"
9
+
8
10
"github.com/naiba/nb/assets"
9
11
"github.com/naiba/nb/singleton"
10
- "github.com/urfave/cli/v2"
11
12
)
12
13
13
14
func init () {
Original file line number Diff line number Diff line change @@ -3,8 +3,9 @@ package cmd
3
3
import (
4
4
"fmt"
5
5
6
- "github.com/naiba/nb/singleton"
7
6
"github.com/urfave/cli/v2"
7
+
8
+ "github.com/naiba/nb/singleton"
8
9
)
9
10
10
11
func init () {
Original file line number Diff line number Diff line change 4
4
"fmt"
5
5
"os"
6
6
7
- "github.com/naiba/nb/singleton"
8
7
"github.com/urfave/cli/v2"
8
+
9
+ "github.com/naiba/nb/singleton"
9
10
)
10
11
11
12
func init () {
Original file line number Diff line number Diff line change 5
5
"net"
6
6
"os"
7
7
8
- "github.com/naiba/nb/singleton"
9
-
10
8
"github.com/urfave/cli/v2"
9
+
10
+ "github.com/naiba/nb/singleton"
11
11
)
12
12
13
13
var rootCmd = & cli.App {
Original file line number Diff line number Diff line change 4
4
"fmt"
5
5
"net"
6
6
7
- "github.com/naiba/nb/singleton"
8
7
"github.com/urfave/cli/v2"
8
+
9
+ "github.com/naiba/nb/singleton"
9
10
)
10
11
11
12
func init () {
Original file line number Diff line number Diff line change 1
1
package cmd
2
2
3
3
import (
4
+ "os"
4
5
"runtime"
5
6
"strings"
6
7
7
8
"github.com/AppleGamer22/cocainate/session"
8
-
9
9
"github.com/urfave/cli/v2"
10
10
)
11
11
@@ -45,22 +45,24 @@ var beepCmd = &cli.Command{
45
45
},
46
46
}
47
47
48
- var s session.Session
48
+ var s * session.Session
49
49
50
50
var awakeCmd = & cli.Command {
51
51
Name : "awake" ,
52
52
Aliases : []string {"a" },
53
53
Usage : "Awake during the command is running." ,
54
54
SkipFlagParsing : true ,
55
55
Before : func (c * cli.Context ) error {
56
- s = session.Session {}
56
+ s = session .New ( 0 , os . Getppid ())
57
57
return s .Start ()
58
58
},
59
59
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
64
66
},
65
67
}
66
68
@@ -70,13 +72,15 @@ var awakeBeepCmd = &cli.Command{
70
72
Usage : "Awake and beep when an command is finished." ,
71
73
SkipFlagParsing : true ,
72
74
Before : func (c * cli.Context ) error {
73
- s = session.Session {}
75
+ s = session .New ( 0 , os . Getppid ())
74
76
return s .Start ()
75
77
},
76
78
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
81
85
},
82
86
}
Original file line number Diff line number Diff line change 4
4
"fmt"
5
5
"net"
6
6
7
- "github.com/naiba/nb/singleton"
8
7
"github.com/urfave/cli/v2"
8
+
9
+ "github.com/naiba/nb/singleton"
9
10
)
10
11
11
12
func init () {
Original file line number Diff line number Diff line change @@ -7,10 +7,11 @@ import (
7
7
"strings"
8
8
"sync"
9
9
10
- "github.com/naiba/nb/model"
11
- "github.com/naiba/nb/singleton"
12
10
"github.com/urfave/cli/v2"
13
11
"golang.org/x/crypto/ssh"
12
+
13
+ "github.com/naiba/nb/model"
14
+ "github.com/naiba/nb/singleton"
14
15
)
15
16
16
17
func init () {
Original file line number Diff line number Diff line change @@ -6,10 +6,6 @@ import (
6
6
7
7
var Config * model.Config
8
8
9
- func init () {
10
-
11
- }
12
-
13
9
func Init (confPath string ) error {
14
10
var err error
15
11
Config , err = model .ReadInConfig (confPath )
You can’t perform that action at this time.
0 commit comments