Skip to content

Commit

Permalink
Merge branch '32-add-force-copy-flag-exec' into 'master'
Browse files Browse the repository at this point in the history
32 Add force flag for sync into container

Closes #32

See merge request asannikov/mgt!34
  • Loading branch information
asannikov committed Jan 20, 2021
2 parents 8772d69 + 5ecce5f commit 4b82641
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 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.8.0 (20.01.2021)
- features
- add force flag for copyto

## 1.7.3 (19.01.2021)
- bugfix
- fix sync destination option
Expand Down
9 changes: 7 additions & 2 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.7.3-brightgreen.svg)](https://github.com/asannikov/jumper/releases/tag/v1.7.3)
[![Release](https://img.shields.io/badge/release-1.8.0-brightgreen.svg)](https://github.com/asannikov/jumper/releases/tag/v1.8.0)

It was not tested on Windows.

Expand Down Expand Up @@ -102,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.7.3
https://github.com/asannikov/jumper/releases/tag/v1.8.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 @@ -202,6 +202,11 @@ here is a list of avalable values:
* `xdebug` - hides xdebug commands

# FAQ
## How to force create path on sync:
`jumper copyto -f src/vendor/module/name`
assume that src/vendor does not exist in container. By this command it will be created recursively.
The same you can do on host: `jumper copyfrom -f src/vendor/module/name`.

## 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
18 changes: 11 additions & 7 deletions app/command/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,17 @@ func SyncCommand(direction string, cfg syncProjectConfig, d syncCommandDialog, o
syncCopyFrom: "cpf",
},
description: map[string]string{
syncCopyTo: "phpContainer is taken from project config file",
syncCopyFrom: "phpContainer is taken from project config file, php and composer commands will be found automatically",
syncCopyTo: "Works only for defined main container. Keep in mind that `docker cp` create only the top folder of the path if all nodes of the path do not exist. For such case use -f flag. It creates all folders recursively.",
syncCopyFrom: "phpContainer is taken from project config file",
},
}

flags := []cli.Flag{}

if direction == syncCopyFrom {
flags = append(flags, &cli.BoolFlag{
flags := []cli.Flag{
&cli.BoolFlag{
Name: "force",
Aliases: []string{"f"},
Usage: "Force create directory for file if it does not exist",
})
},
}

return &cli.Command{
Expand Down Expand Up @@ -127,6 +125,12 @@ func SyncCommand(direction string, cfg syncProjectConfig, d syncCommandDialog, o
err = os.MkdirAll(args[2]+filepath.Base(syncPath), os.ModePerm)
}

if direction == syncCopyTo && c.Bool("f") == true {
fmt.Printf("Path %s was created", cfg.GetProjectDockerPath()+syncPath)
// @todo - use go client logic, branch 32-add-force-copy-flag
err = execCommand("docker", []string{"exec", cfg.GetProjectMainContainer(), "mkdir", "-p", cfg.GetProjectDockerPath() + syncPath}, c.App)
}

if err != nil {
return err
}
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.7.3"
const version = "1.8.0"

func main() {

Expand Down

0 comments on commit 4b82641

Please sign in to comment.