From 639e1e07e41f40fb30d2759baaf407b7a09cc937 Mon Sep 17 00:00:00 2001 From: Dominik Schulz Date: Tue, 25 Jul 2017 16:36:11 +0200 Subject: [PATCH] Simplify mounts add by infering local path (#219) --- action/mount.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/action/mount.go b/action/mount.go index 2f2848e509..ae017da50f 100644 --- a/action/mount.go +++ b/action/mount.go @@ -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" @@ -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 [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) } @@ -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 }