Skip to content

Commit

Permalink
Simplify mounts add by infering local path (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikschulz authored Jul 25, 2017
1 parent 03d8e34 commit 639e1e0
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions action/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"sort"

"github.com/fatih/color"
"github.com/justwatchcom/gopass/config"
"github.com/justwatchcom/gopass/store"
"github.com/justwatchcom/gopass/tree/simple"
"github.com/urfave/cli"
Expand Down Expand Up @@ -56,14 +57,18 @@ func (s *Action) MountsComplete(*cli.Context) {

// MountAdd adds a new mount
func (s *Action) MountAdd(c *cli.Context) error {
if len(c.Args()) != 2 {
return fmt.Errorf("usage: gopass mount add [alias] [local path]")
alias := c.Args().Get(0)
localPath := c.Args().Get(1)
if alias == "" {
return fmt.Errorf("usage: gopass mount add <alias> [local path]")
}
if localPath == "" {
localPath = config.PwStoreDir(alias)
}
keys := make([]string, 0, 1)
if k := c.String("init"); k != "" {
keys = append(keys, k)
}
alias, localPath := c.Args()[0], c.Args()[1]
if s.Store.Exists(alias) {
fmt.Printf(color.YellowString("WARNING: shadowing %s entry\n"), alias)
}
Expand All @@ -74,6 +79,6 @@ func (s *Action) MountAdd(c *cli.Context) error {
return err
}

color.Green("Mounted %s as %s", c.Args()[0], c.Args()[1])
color.Green("Mounted %s as %s", alias, localPath)
return nil
}

0 comments on commit 639e1e0

Please sign in to comment.