Skip to content

Commit

Permalink
allow render layout to current dir
Browse files Browse the repository at this point in the history
  • Loading branch information
reddec committed Aug 3, 2022
1 parent b049265 commit ad9f5e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 125,9 @@ state any changes (for legal details please read LICENSE file).
* `auto` (default, but it can be changed in [configuration](#configuration)) in case git installed (`git` binary
accessible) and git version is 2.13 or higher `native` will be used, otherwise `embedded`

* (v1.4.0 ) if `destination` is not set, the current working directory will be used


##### set

Since v1.3.1
Expand Down
6 changes: 5 additions & 1 deletion cmd/layout/commands/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 41,18 @@ type NewCommand struct {
Git gitMode `short:"g" long:"git" env:"GIT" description:"Git client. Default value as in config file (auto)" choice:"auto" choice:"native" choice:"embedded"`
Args struct {
URL string `positional-arg-name:"source" required:"yes" description:"URL, abbreviation or path to layout"`
Dest string `positional-arg-name:"destination" required:"yes" description:"Destination directory, will be created"`
Dest string `positional-arg-name:"destination" description:"Destination directory, will be created if not exists. If not set - current dir will be used"`
} `positional-args:"yes"`
}

func (cmd NewCommand) Execute([]string) error {
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, os.Kill)
defer cancel()

if cmd.Args.Dest == "" {
cmd.Args.Dest, _ = os.Getwd()
}

config, err := LoadConfig(cmd.configFile())
if err != nil {
return fmt.Errorf("read config %s: %w", cmd.configFile(), err)
Expand Down

0 comments on commit ad9f5e4

Please sign in to comment.