Skip to content

Commit 7d3c572

Browse files
committed
Merge branch '27-fix-shell' into 'master'
Resolve "jumper shell outside project does not detect the project" Closes #27 See merge request asannikov/mgt!27
2 parents c39b167 + 07c4518 commit 7d3c572

File tree

6 files changed

+49
-18
lines changed

6 files changed

+49
-18
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## 1.5.7 (13.01.2021)
4+
- bugfix
5+
- 27 Fix shell type detection outside project
6+
37
## 1.5.6 (13.01.2021)
48
- bugfix
59
- refactoring: changed files hierarchy in project

Readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ I was inspired by [Mark's Shust](https://github.com/markshust/docker-magento) so
66

77
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://github.com/asannikov/jumper/blob/master/LICENSE)
88
[![Build Status](https://travis-ci.com/asannikov/jumper.svg?branch=master)](https://travis-ci.com/asannikov/jumper)
9-
[![Release](https://img.shields.io/badge/release-1.5.3-brightgreen.svg)](https://github.com/asannikov/jumper/releases/tag/v1.5.6)
9+
[![Release](https://img.shields.io/badge/release-1.5.3-brightgreen.svg)](https://github.com/asannikov/jumper/releases/tag/v1.5.7)
1010

1111
It was not tested on Windows.
1212

@@ -103,7 +103,7 @@ Every stable release has attached sources for "linux/amd64", "linux/386", "darwi
103103

104104
For example:
105105
```
106-
https://github.com/asannikov/jumper/releases/tag/v1.5.6
106+
https://github.com/asannikov/jumper/releases/tag/v1.5.7
107107
```
108108
Find related source there and download it. Now you can place use source at any place you want on your machine or make it global in a standard way.
109109

app/test.go renamed to app/app_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ func (tfs *testFileSystem) GetWd() (string, error) {
9090
return tfs.getWd()
9191
}
9292

93+
// TestDefinePaths tests definePaths
9394
func TestDefinePaths(t *testing.T) {
9495
cfg := &config.Config{
9596
ProjectFile: confgFile,
@@ -116,6 +117,7 @@ func TestDefinePaths(t *testing.T) {
116117
assert.EqualError(t, err, "Cannot read directory")
117118
}
118119

120+
// TestSeekPathDefinePaths tests seekPath
119121
func TestSeekPathDefinePaths(t *testing.T) {
120122
cfg := &config.Config{
121123
ProjectFile: confgFile,
@@ -133,6 +135,7 @@ func TestSeekPathDefinePaths(t *testing.T) {
133135
assert.EqualError(t, err, "Cannot read directory")
134136
}
135137

138+
// TestSeekPathLoadConfig tests seekPath
136139
func TestSeekPathLoadConfig(t *testing.T) {
137140
cfg := &config.Config{
138141
ProjectFile: confgFile,
@@ -155,6 +158,7 @@ func TestSeekPathLoadConfig(t *testing.T) {
155158
assert.EqualError(t, err, "Cannot read config file")
156159
}
157160

161+
// TestSeekPathGetWd tests seekPath
158162
func TestSeekPathGetWd(t *testing.T) {
159163
cfg := &config.Config{
160164
ProjectFile: confgFile,
@@ -180,6 +184,7 @@ func TestSeekPathGetWd(t *testing.T) {
180184
assert.EqualError(t, err, "Cannot get current directory")
181185
}
182186

187+
// TestSeekPathGetProjectNameList tests seekPath
183188
func TestSeekPathGetProjectNameList(t *testing.T) {
184189
cfg := &config.Config{
185190
ProjectFile: confgFile,
@@ -217,6 +222,7 @@ func TestSeekPathGetProjectNameList(t *testing.T) {
217222
assert.Equal(t, 2, len(pl))
218223
}
219224

225+
// TestSeekPathrunDialogCase1 tests seekPath
220226
func TestSeekPathrunDialogCase1(t *testing.T) {
221227
cfg := &config.Config{
222228
ProjectFile: confgFile,
@@ -255,6 +261,7 @@ func TestSeekPathrunDialogCase1(t *testing.T) {
255261
assert.EqualError(t, err, "Error SelectProject dialog")
256262
}
257263

264+
// TestSeekPathrunDialogCase2 tests seekPath
258265
func TestSeekPathrunDialogCase2(t *testing.T) {
259266
cfg := &config.Config{
260267
ProjectFile: confgFile,
@@ -305,6 +312,7 @@ func TestSeekPathrunDialogCase2(t *testing.T) {
305312
assert.EqualError(t, err, "Is ok")
306313
}
307314

315+
// TestSeekPathrunDialogCase3 tests seekPath
308316
func TestSeekPathrunDialogCase3(t *testing.T) {
309317
cfg := &config.Config{
310318
ProjectFile: confgFile,
@@ -358,6 +366,7 @@ func TestSeekPathrunDialogCase3(t *testing.T) {
358366
assert.EqualError(t, err, "Is ok")
359367
}
360368

369+
// TestSeekPathrunDialogCase4 tests seekPath
361370
func TestSeekPathrunDialogCase4(t *testing.T) {
362371
cfg := &config.Config{
363372
ProjectFile: confgFile,
@@ -411,6 +420,7 @@ func TestSeekPathrunDialogCase4(t *testing.T) {
411420
assert.EqualError(t, err, "Add project name dialog error")
412421
}
413422

423+
// TestSeekPathrunDialogCase5 tests seekPath
414424
func TestSeekPathrunDialogCase5(t *testing.T) {
415425
cfg := &config.Config{
416426
ProjectFile: confgFile,
@@ -487,7 +497,7 @@ func TestSeekPathrunDialogCase5(t *testing.T) {
487497
assert.EqualError(t, err, "Cannot save project config file")
488498
}
489499

490-
// The same as TestSeekPathrunDialogCase5, but checks return nil for seek function
500+
// TestSeekPathrunDialogCase6 tests seekPath. The same as TestSeekPathrunDialogCase5, but checks return nil for seek function
491501
// see saveConfigFile return change
492502
func TestSeekPathrunDialogCase6(t *testing.T) {
493503
cfg := &config.Config{

app/command/cli.go

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,18 @@ import (
1010
"github.com/urfave/cli/v2" // imports as package "cli"
1111
)
1212

13+
type commandHandler func(chc commandHandleProjectConfig) string
14+
1315
type cliCommand struct {
1416
usage map[string]string
1517
aliases map[string]string
1618
args map[string][]string
17-
command map[string]string
19+
command map[string]func(commandHandleProjectConfig) string
1820
}
1921

20-
func (cli *cliCommand) GetCommand(cmd string) string {
21-
return cli.command[cmd]
22+
func (cli *cliCommand) GetCommand(cmd string, cfg commandHandleProjectConfig) string {
23+
command := cli.command[cmd]
24+
return command(cfg)
2225
}
2326

2427
func (cli *cliCommand) GetArgs() map[string][]string {
@@ -35,6 +38,10 @@ type callCliCommandDialog interface {
3538
SetMainContaner([]string) (int, string, error)
3639
}
3740

41+
type commandHandleProjectConfig interface {
42+
GetShell() string
43+
}
44+
3845
// CallCliCommand calls a range of differnt cli commands
3946
func CallCliCommand(commandName string, initf func(bool) string, cfg cliCommandHandleProjectConfig, d callCliCommandDialog, cl containerlist) *cli.Command {
4047
clic := &cliCommand{
@@ -59,12 +66,22 @@ func CallCliCommand(commandName string, initf func(bool) string, cfg cliCommandH
5966
"clinotty": []string{"-i"},
6067
"clirootnotty": []string{"-u", "root", "-i"},
6168
},
62-
command: map[string]string{
63-
"cli": "",
64-
"sh": cfg.GetShell(),
65-
"clinotty": "",
66-
"cliroot": "",
67-
"clirootnotty": "",
69+
command: map[string]func(commandHandleProjectConfig) string{
70+
"cli": func(c commandHandleProjectConfig) string {
71+
return ""
72+
},
73+
"sh": func(c commandHandleProjectConfig) string {
74+
return c.GetShell()
75+
},
76+
"clinotty": func(c commandHandleProjectConfig) string {
77+
return ""
78+
},
79+
"cliroot": func(c commandHandleProjectConfig) string {
80+
return ""
81+
},
82+
"clirootnotty": func(c commandHandleProjectConfig) string {
83+
return ""
84+
},
6885
},
6986
}
7087

@@ -95,7 +112,7 @@ func CallCliCommand(commandName string, initf func(bool) string, cfg cliCommandH
95112
}
96113

97114
type cliCommandInterface interface {
98-
GetCommand(string) string
115+
GetCommand(string, commandHandleProjectConfig) string
99116
GetArgs() map[string][]string
100117
}
101118

@@ -125,11 +142,11 @@ func cliCommandHandle(index string, cfg cliCommandHandleProjectConfig, d cliComm
125142

126143
initArgs = append(initArgs, cfg.GetProjectMainContainer())
127144

128-
if c.GetCommand(index) != "" {
129-
initArgs = append(initArgs, c.GetCommand(index))
145+
if c.GetCommand(index, cfg) != "" {
146+
initArgs = append(initArgs, c.GetCommand(index, cfg))
130147
}
131148

132-
if c.GetCommand(index) == "" && a.Get(0) == "" {
149+
if c.GetCommand(index, cfg) == "" && a.Get(0) == "" {
133150
return []string{}, errors.New("Please specify a CLI command (ex. ls)")
134151
}
135152

app/command/cli_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ type testCli struct {
4141
command map[string]string
4242
}
4343

44-
func (tc *testCli) GetCommand(cmd string) string {
44+
func (tc *testCli) GetCommand(cmd string, cfg commandHandleProjectConfig) string {
4545
return tc.command[cmd]
4646
}
4747

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/urfave/cli/v2"
1010
)
1111

12-
const version = "1.5.6"
12+
const version = "1.5.7"
1313

1414
func main() {
1515

0 commit comments

Comments
 (0)