Skip to content

Commit

Permalink
13 Add scope config
Browse files Browse the repository at this point in the history
  • Loading branch information
asannikov committed Jan 13, 2021
1 parent 7d3c572 commit ff5c576
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 1.6.0 (14.01.2021)
- features
- 13 Add scope command config. User can hide unnecessary commands in global config file (composer, xdebug).

## 1.5.7 (13.01.2021)
- bugfix
- 27 Fix shell type detection outside project
Expand Down
59 changes: 56 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ I was inspired by [Mark's Shust](https://github.com/markshust/docker-magento) so

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

It was not tested on Windows.

Expand All @@ -31,7 +31,6 @@ PHP
* Laravel artisan support
* Docker extended managment
* GIT routines
* Extendable jumper config options
* Kubernetes management

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.
Expand Down Expand Up @@ -103,7 +102,7 @@ Every stable release has attached sources for "linux/amd64", "linux/386", "darwi

For example:
```
https://github.com/asannikov/jumper/releases/tag/v1.5.7
https://github.com/asannikov/jumper/releases/tag/v1.6.0
```
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.

Expand Down Expand Up @@ -147,6 +146,60 @@ implemented commands:
shell Change shell type for a project
```

# Project config example - jumper.json
```
{
"name": "Project Name",
"main_container": "php_container",
"start_command": "docker-compose up -d",
"path": "/var/www/src",
"xdebug_location": "local",
"xdebug_path_cli": "/path/to/project/config/xdebug_cli.ini",
"xdebug_path_fpm": "/path/to/project/config/xdebug_fpm.ini",
"shell": "bash"
}
```

all these options are managed using jumper command. **It's not recommended to edit manually.**

# Global conifg file example - ~/.jumper.json
```
{
"projects": [
{
"path": "/path/to/project1",
"name": "project1"
},
{
"path": "/path/to/project2",
"name": "project2"
}
],
"copyright_text": false,
"docker_service": "open --hide -a Docker",
"inactive_command_types": [
"compose",
"xdebug"
]
}
```

# Available options for global config ~/.jumper.json

## Hide copyright text
Add `"copyright_text": false,`

It can be done using jumper command though.

## Permanent hiding some types of commands
add `"inactive_command_types": ["type1","type2"],`

It can be done only directly in config file.

here is a list of avalable values:
* `composer` - hides all composer commands
* `xdebug` - hides xdebug commands

# FAQ
## How to change shell type:
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.
Expand Down
2 changes: 2 additions & 0 deletions app/command/composer.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type callComposerCommandProjectConfig interface {
GetProjectDockerPath() string
GetProjectMainContainer() string
SaveContainerNameToProjectConfig(string) error
GetCommandInactveStatus(string) bool
}

type callComposerCommandDialog interface {
Expand Down Expand Up @@ -108,6 +109,7 @@ func CallComposerCommand(composercommand string, initf func(bool) string, cfg ca
Aliases: []string{cmp.aliases[index]},
Usage: cmp.usage[index],
Description: cmp.description[index],
Hidden: cfg.GetCommandInactveStatus("composer"),
SkipFlagParsing: true,
Action: func(c *cli.Context) (err error) {
initf(true)
Expand Down
2 changes: 2 additions & 0 deletions app/command/xdebug.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type xdebugProjectConfig interface {
SaveDockerCliXdebugIniFilePath(string) error
SaveDockerFpmXdebugIniFilePath(string) error
SaveXDebugConifgLocaton(string) error
GetCommandInactveStatus(string) bool
}

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

Expand Down
7 changes: 6 additions & 1 deletion app/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ func (c *Config) LoadConfig(seekProject bool) (err error) {
return err
}

// GetCommandInactveStatus gets command status
func (c *Config) GetCommandInactveStatus(cmd string) bool {
return c.globalConfig.GetCommandInactveStatus(cmd)
}

// FindProjectPathInJSON check if project path in the json
func (c *Config) FindProjectPathInJSON(pc projectSettings) {
c.globalConfig.FindProjectPathInJSON(func(p GlobalProjectConfig) (bool, error) {
Expand Down Expand Up @@ -153,7 +158,7 @@ func (c *Config) AddProjectConfigFile() (err error) {
}

c.globalConfig.Projects = append(c.globalConfig.Projects, fpc)

c.globalConfig.InactiveCommandTypes = []string{"composer", "php"}
return c.fileSystem.SaveConfigFile(c.globalConfig, c.UserFile)
}

Expand Down
17 changes: 14 additions & 3 deletions app/config/globalConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ type GlobalProjectConfig struct {

// GlobalConfig contains file config
type GlobalConfig struct {
Projects []GlobalProjectConfig `json:"projects"`
Copyright bool `json:"copyright_text"`
DockerCommand string `json:"docker_service"`
Projects []GlobalProjectConfig `json:"projects"`
Copyright bool `json:"copyright_text"`
DockerCommand string `json:"docker_service"`
InactiveCommandTypes []string `json:"inactive_command_types"`
}

// SetDockerCommand define docker command
Expand Down Expand Up @@ -56,6 +57,16 @@ func (g *GlobalConfig) GetProjectNameList() []string {
return pl
}

// GetCommandStatus checks command visibility
func (g *GlobalConfig) GetCommandInactveStatus(cmd string) bool {
for _, a := range g.InactiveCommandTypes {
if a == cmd {
return true
}
}
return false
}

// FindProjectPathInJSON find project path in json
func (g *GlobalConfig) FindProjectPathInJSON(f func(GlobalProjectConfig) (bool, error)) error {
for _, p := range g.Projects {
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/urfave/cli/v2"
)

const version = "1.5.7"
const version = "1.6.0"

func main() {

Expand Down

0 comments on commit ff5c576

Please sign in to comment.