Skip to content

Commit

Permalink
Create wizard
Browse files Browse the repository at this point in the history
RELEASE_NOTES=[ENHANCEMENT] Template support for the create wizard

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
  • Loading branch information
dominikschulz committed Dec 23, 2021
1 parent ffaa9e3 commit 155ee37
Show file tree
Hide file tree
Showing 9 changed files with 475 additions and 554 deletions.
6 changes: 6 additions & 0 deletions internal/action/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ func (s *Action) Config(c *cli.Context) error {
func (s *Action) printConfigValues(ctx context.Context, needles ...string) {
m := s.cfg.ConfigMap()
for _, k := range filterMap(m, needles) {
// if only a single key is requested, print only the value
// useful for scriping, e.g. `$ cd $(gopass config path)`
if len(needles) == 1 {
out.Printf(ctx, "%s", m[k])
continue
}
out.Printf(ctx, "%s: %s", k, m[k])
}
for alias, path := range s.cfg.Mounts {
Expand Down
8 changes: 4 additions & 4 deletions internal/action/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ parsing: true
defer buf.Reset()

assert.NoError(t, act.setConfigValue(ctx, "nopager", "true"))
assert.Equal(t, "nopager: true", strings.TrimSpace(buf.String()), "action.setConfigValue")
assert.Equal(t, "true", strings.TrimSpace(buf.String()), "action.setConfigValue")
})

t.Run("set invalid config value", func(t *testing.T) {
Expand All @@ -70,7 +70,7 @@ parsing: true

act.printConfigValues(ctx, "nopager")

want := "nopager: true"
want := "true"
assert.Equal(t, want, strings.TrimSpace(buf.String()), "action.printConfigValues")
})

Expand Down Expand Up @@ -98,15 +98,15 @@ parsing: true

c := gptest.CliCtx(ctx, t, "autoimport")
assert.NoError(t, act.Config(c))
assert.Equal(t, "autoimport: true", strings.TrimSpace(buf.String()))
assert.Equal(t, "true", strings.TrimSpace(buf.String()))
})

t.Run("disable autoimport", func(t *testing.T) {
defer buf.Reset()

c := gptest.CliCtx(ctx, t, "autoimport", "false")
assert.NoError(t, act.Config(c))
assert.Equal(t, "autoimport: false", strings.TrimSpace(buf.String()))
assert.Equal(t, "false", strings.TrimSpace(buf.String()))
})

t.Run("complete config items", func(t *testing.T) {
Expand Down
Loading

0 comments on commit 155ee37

Please sign in to comment.