Skip to content

Commit 1de13cf

Browse files
committed
Merge branch '13-scope-command-config' into 'master'
13 Add scope config Closes #13 See merge request asannikov/mgt!28
2 parents 7d3c572 + ff5c576 commit 1de13cf

File tree

7 files changed

+85
-8
lines changed

7 files changed

+85
-8
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.6.0 (14.01.2021)
4+
- features
5+
- 13 Add scope command config. User can hide unnecessary commands in global config file (composer, xdebug).
6+
37
## 1.5.7 (13.01.2021)
48
- bugfix
59
- 27 Fix shell type detection outside project

Readme.md

Lines changed: 56 additions & 3 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.7)
9+
[![Release](https://img.shields.io/badge/release-1.5.3-brightgreen.svg)](https://github.com/asannikov/jumper/releases/tag/v1.6.0)
1010

1111
It was not tested on Windows.
1212

@@ -31,7 +31,6 @@ PHP
3131
* Laravel artisan support
3232
* Docker extended managment
3333
* GIT routines
34-
* Extendable jumper config options
3534
* Kubernetes management
3635

3736
I'll highly appreciate for testing and any ideas where this tool can be useful. Please, write your suggestions or your experience in the issues.
@@ -103,7 +102,7 @@ Every stable release has attached sources for "linux/amd64", "linux/386", "darwi
103102

104103
For example:
105104
```
106-
https://github.com/asannikov/jumper/releases/tag/v1.5.7
105+
https://github.com/asannikov/jumper/releases/tag/v1.6.0
107106
```
108107
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.
109108

@@ -147,6 +146,60 @@ implemented commands:
147146
shell Change shell type for a project
148147
```
149148

149+
# Project config example - jumper.json
150+
```
151+
{
152+
"name": "Project Name",
153+
"main_container": "php_container",
154+
"start_command": "docker-compose up -d",
155+
"path": "/var/www/src",
156+
"xdebug_location": "local",
157+
"xdebug_path_cli": "/path/to/project/config/xdebug_cli.ini",
158+
"xdebug_path_fpm": "/path/to/project/config/xdebug_fpm.ini",
159+
"shell": "bash"
160+
}
161+
```
162+
163+
all these options are managed using jumper command. **It's not recommended to edit manually.**
164+
165+
# Global conifg file example - ~/.jumper.json
166+
```
167+
{
168+
"projects": [
169+
{
170+
"path": "/path/to/project1",
171+
"name": "project1"
172+
},
173+
{
174+
"path": "/path/to/project2",
175+
"name": "project2"
176+
}
177+
],
178+
"copyright_text": false,
179+
"docker_service": "open --hide -a Docker",
180+
"inactive_command_types": [
181+
"compose",
182+
"xdebug"
183+
]
184+
}
185+
```
186+
187+
# Available options for global config ~/.jumper.json
188+
189+
## Hide copyright text
190+
Add `"copyright_text": false,`
191+
192+
It can be done using jumper command though.
193+
194+
## Permanent hiding some types of commands
195+
add `"inactive_command_types": ["type1","type2"],`
196+
197+
It can be done only directly in config file.
198+
199+
here is a list of avalable values:
200+
* `composer` - hides all composer commands
201+
* `xdebug` - hides xdebug commands
202+
150203
# FAQ
151204
## How to change shell type:
152205
Container might use only sh shell type and no bash. By default jumper uses `sh`. But you can use `bash` or even `csh`, `ksh` or `zsh`. Call `jumper shell` with no option and select shell type. It will be saved into project config `jumper.json` in `shell` node.

app/command/composer.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ type callComposerCommandProjectConfig interface {
6161
GetProjectDockerPath() string
6262
GetProjectMainContainer() string
6363
SaveContainerNameToProjectConfig(string) error
64+
GetCommandInactveStatus(string) bool
6465
}
6566

6667
type callComposerCommandDialog interface {
@@ -108,6 +109,7 @@ func CallComposerCommand(composercommand string, initf func(bool) string, cfg ca
108109
Aliases: []string{cmp.aliases[index]},
109110
Usage: cmp.usage[index],
110111
Description: cmp.description[index],
112+
Hidden: cfg.GetCommandInactveStatus("composer"),
111113
SkipFlagParsing: true,
112114
Action: func(c *cli.Context) (err error) {
113115
initf(true)

app/command/xdebug.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type xdebugProjectConfig interface {
2525
SaveDockerCliXdebugIniFilePath(string) error
2626
SaveDockerFpmXdebugIniFilePath(string) error
2727
SaveXDebugConifgLocaton(string) error
28+
GetCommandInactveStatus(string) bool
2829
}
2930

3031
type xdebugArgsProjectConfig interface {
@@ -96,6 +97,7 @@ func XDebugCommand(xdebugAction string, initf func(bool) string, dockerStatus bo
9697
Usage: x.usage[xdebugAction],
9798
Description: x.description[xdebugAction],
9899
SkipFlagParsing: false,
100+
Hidden: cfg.GetCommandInactveStatus("xdebug"),
99101
Action: func(c *cli.Context) (err error) {
100102
currentPath := initf(true)
101103

app/config/config.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ func (c *Config) LoadConfig(seekProject bool) (err error) {
9898
return err
9999
}
100100

101+
// GetCommandInactveStatus gets command status
102+
func (c *Config) GetCommandInactveStatus(cmd string) bool {
103+
return c.globalConfig.GetCommandInactveStatus(cmd)
104+
}
105+
101106
// FindProjectPathInJSON check if project path in the json
102107
func (c *Config) FindProjectPathInJSON(pc projectSettings) {
103108
c.globalConfig.FindProjectPathInJSON(func(p GlobalProjectConfig) (bool, error) {
@@ -153,7 +158,7 @@ func (c *Config) AddProjectConfigFile() (err error) {
153158
}
154159

155160
c.globalConfig.Projects = append(c.globalConfig.Projects, fpc)
156-
161+
c.globalConfig.InactiveCommandTypes = []string{"composer", "php"}
157162
return c.fileSystem.SaveConfigFile(c.globalConfig, c.UserFile)
158163
}
159164

app/config/globalConfig.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ type GlobalProjectConfig struct {
88

99
// GlobalConfig contains file config
1010
type GlobalConfig struct {
11-
Projects []GlobalProjectConfig `json:"projects"`
12-
Copyright bool `json:"copyright_text"`
13-
DockerCommand string `json:"docker_service"`
11+
Projects []GlobalProjectConfig `json:"projects"`
12+
Copyright bool `json:"copyright_text"`
13+
DockerCommand string `json:"docker_service"`
14+
InactiveCommandTypes []string `json:"inactive_command_types"`
1415
}
1516

1617
// SetDockerCommand define docker command
@@ -56,6 +57,16 @@ func (g *GlobalConfig) GetProjectNameList() []string {
5657
return pl
5758
}
5859

60+
// GetCommandStatus checks command visibility
61+
func (g *GlobalConfig) GetCommandInactveStatus(cmd string) bool {
62+
for _, a := range g.InactiveCommandTypes {
63+
if a == cmd {
64+
return true
65+
}
66+
}
67+
return false
68+
}
69+
5970
// FindProjectPathInJSON find project path in json
6071
func (g *GlobalConfig) FindProjectPathInJSON(f func(GlobalProjectConfig) (bool, error)) error {
6172
for _, p := range g.Projects {

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.7"
12+
const version = "1.6.0"
1313

1414
func main() {
1515

0 commit comments

Comments
 (0)