Skip to content

Commit

Permalink
v0.0.28: fix org flag
Browse files Browse the repository at this point in the history
  • Loading branch information
geemus committed Apr 30, 2024
1 parent 60438fa commit e4ca5ed
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions trust/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import (
var CmdTrustAudit = cli.NewCmd[Audit](CmdTrust, "audit", func(cmd *cobra.Command) {
cfg := cli.ConfigFromCmd(cmd)

cmd.Flags().StringVarP(&cfg.Trust.Org, "organization", "o", "", "Organization to trust.")
cmd.Flags().StringVarP(&cfg.Trust.Org, "org", "o", "", "Organization to trust.")
cmd.Flags().StringVarP(&cfg.Trust.Realm, "realm", "r", "", "Realm to trust.")
cmd.Flags().StringSliceVar(&cfg.Trust.Stores, "trust-stores", []string{"homebrew", "nss", "system"}, "Trust stores to update.")

cmd.MarkFlagsRequiredTogether("organization", "realm")
cmd.MarkFlagsRequiredTogether("org", "realm")
})

type Audit struct{}
Expand Down
12 changes: 6 additions & 6 deletions trust/audit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ func TestCmdTrustAudit(t *testing.T) {
cmdtest.TestHelp(t, CmdTrustAudit, "trust", "audit", "--help")
})

t.Run("--organization testOrg", func(t *testing.T) {
err := cmdtest.TestError(t, CmdTrustAudit, "--organization", "testOrg")
require.ErrorContains(t, err, "if any flags in the group [organization realm] are set they must all be set; missing [realm]")
t.Run("--org testOrg", func(t *testing.T) {
err := cmdtest.TestError(t, CmdTrustAudit, "--org", "testOrg")
require.ErrorContains(t, err, "if any flags in the group [org realm] are set they must all be set; missing [realm]")
})

t.Run("-o testOrg", func(t *testing.T) {
err := cmdtest.TestError(t, CmdTrustAudit, "-o", "testOrg")
require.ErrorContains(t, err, "if any flags in the group [organization realm] are set they must all be set; missing [realm]")
require.ErrorContains(t, err, "if any flags in the group [org realm] are set they must all be set; missing [realm]")
})

t.Run("-o testOrg -r testRealm", func(t *testing.T) {
Expand All @@ -39,12 +39,12 @@ func TestCmdTrustAudit(t *testing.T) {

t.Run("--realm testRealm", func(t *testing.T) {
err := cmdtest.TestError(t, CmdTrustAudit, "--realm", "testRealm")
require.ErrorContains(t, err, "if any flags in the group [organization realm] are set they must all be set; missing [organization]")
require.ErrorContains(t, err, "if any flags in the group [org realm] are set they must all be set; missing [org]")
})

t.Run("-r testRealm", func(t *testing.T) {
err := cmdtest.TestError(t, CmdTrustAudit, "-r", "testRealm")
require.ErrorContains(t, err, "if any flags in the group [organization realm] are set they must all be set; missing [organization]")
require.ErrorContains(t, err, "if any flags in the group [org realm] are set they must all be set; missing [org]")
})

t.Run("default --trust-stores", func(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions trust/clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ var CmdTrustClean = cli.NewCmd[Clean](CmdTrust, "clean", func(cmd *cobra.Command
cfg := cli.ConfigFromCmd(cmd)

cmd.Flags().StringSliceVar(&cfg.Trust.Clean.States, "cert-states", []string{"expired"}, "Cert states to clean.")
cmd.Flags().StringVarP(&cfg.Trust.Org, "organization", "o", "", "Organization to trust.")
cmd.Flags().StringVarP(&cfg.Trust.Org, "org", "o", "", "Organization to trust.")
cmd.Flags().BoolVar(&cfg.Trust.NoSudo, "no-sudo", false, "Disable sudo prompts.")
cmd.Flags().StringVarP(&cfg.Trust.Realm, "realm", "r", "", "Realm to trust.")
cmd.Flags().StringSliceVar(&cfg.Trust.Stores, "trust-stores", []string{"homebrew", "nss", "system"}, "Trust stores to update.")

cmd.MarkFlagsRequiredTogether("organization", "realm")
cmd.MarkFlagsRequiredTogether("org", "realm")

cmd.Hidden = true
})
Expand Down
12 changes: 6 additions & 6 deletions trust/clean_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ func TestCmdTrustClean(t *testing.T) {
require.Equal(t, []string{"all"}, cfg.Trust.Clean.States)
})

t.Run("--organization testOrg", func(t *testing.T) {
err := cmdtest.TestError(t, CmdTrustClean, "--organization", "testOrg")
require.ErrorContains(t, err, "if any flags in the group [organization realm] are set they must all be set; missing [realm]")
t.Run("--org testOrg", func(t *testing.T) {
err := cmdtest.TestError(t, CmdTrustClean, "--org", "testOrg")
require.ErrorContains(t, err, "if any flags in the group [org realm] are set they must all be set; missing [realm]")
})

t.Run("-o testOrg", func(t *testing.T) {
err := cmdtest.TestError(t, CmdTrustClean, "-o", "testOrg")
require.ErrorContains(t, err, "if any flags in the group [organization realm] are set they must all be set; missing [realm]")
require.ErrorContains(t, err, "if any flags in the group [org realm] are set they must all be set; missing [realm]")
})

t.Run("-o testOrg -r testRealm", func(t *testing.T) {
Expand All @@ -38,12 +38,12 @@ func TestCmdTrustClean(t *testing.T) {

t.Run("--realm testRealm", func(t *testing.T) {
err := cmdtest.TestError(t, CmdTrustClean, "--realm", "testRealm")
require.ErrorContains(t, err, "if any flags in the group [organization realm] are set they must all be set; missing [organization]")
require.ErrorContains(t, err, "if any flags in the group [org realm] are set they must all be set; missing [org]")
})

t.Run("-r testRealm", func(t *testing.T) {
err := cmdtest.TestError(t, CmdTrustClean, "-r", "testRealm")
require.ErrorContains(t, err, "if any flags in the group [organization realm] are set they must all be set; missing [organization]")
require.ErrorContains(t, err, "if any flags in the group [org realm] are set they must all be set; missing [org]")
})

t.Run("default --trust-stores", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion trust/testdata/TestCmdTrust/--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Available Commands:
Flags:
-h, --help help for trust
--no-sudo Disable sudo prompts.
-o, --organization string Organization to trust.
-o, --org string Organization to trust.
-r, --realm string Realm to trust.
--trust-stores strings Trust stores to update. (default [homebrew,nss,system])

Expand Down
2 changes: 1 addition & 1 deletion trust/testdata/TestCmdTrustAudit/--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ Usage:

Flags:
-h, --help help for audit
-o, --organization string Organization to trust.
-o, --org string Organization to trust.
-r, --realm string Realm to trust.
--trust-stores strings Trust stores to update. (default [homebrew,nss,system])
2 changes: 1 addition & 1 deletion trust/testdata/TestCmdTrustClean/--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ Flags:
--cert-states strings Cert states to clean. (default [expired])
-h, --help help for clean
--no-sudo Disable sudo prompts.
-o, --organization string Organization to trust.
-o, --org string Organization to trust.
-r, --realm string Realm to trust.
--trust-stores strings Trust stores to update. (default [homebrew,nss,system])
4 changes: 2 additions & 2 deletions trust/trust.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ import (
var CmdTrust = cli.NewCmd[Command](cli.CmdRoot, "trust", func(cmd *cobra.Command) {
cfg := cli.ConfigFromCmd(cmd)

cmd.Flags().StringVarP(&cfg.Trust.Org, "organization", "o", "", "Organization to trust.")
cmd.Flags().StringVarP(&cfg.Trust.Org, "org", "o", "", "Organization to trust.")
cmd.Flags().BoolVar(&cfg.Trust.NoSudo, "no-sudo", false, "Disable sudo prompts.")
cmd.Flags().StringVarP(&cfg.Trust.Realm, "realm", "r", "", "Realm to trust.")
cmd.Flags().StringSliceVar(&cfg.Trust.Stores, "trust-stores", []string{"homebrew", "nss", "system"}, "Trust stores to update.")

cmd.MarkFlagsRequiredTogether("organization", "realm")
cmd.MarkFlagsRequiredTogether("org", "realm")
})

type Command struct {
Expand Down
12 changes: 6 additions & 6 deletions trust/trust_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ func TestCmdTrust(t *testing.T) {
require.Equal(t, true, cfg.Trust.NoSudo)
})

t.Run("--organization testOrg", func(t *testing.T) {
err := cmdtest.TestError(t, CmdTrust, "--organization", "testOrg")
require.ErrorContains(t, err, "if any flags in the group [organization realm] are set they must all be set; missing [realm]")
t.Run("--org testOrg", func(t *testing.T) {
err := cmdtest.TestError(t, CmdTrust, "--org", "testOrg")
require.ErrorContains(t, err, "if any flags in the group [org realm] are set they must all be set; missing [realm]")
})

t.Run("-o testOrg", func(t *testing.T) {
err := cmdtest.TestError(t, CmdTrust, "-o", "testOrg")
require.ErrorContains(t, err, "if any flags in the group [organization realm] are set they must all be set; missing [realm]")
require.ErrorContains(t, err, "if any flags in the group [org realm] are set they must all be set; missing [realm]")
})

t.Run("-o testOrg -r testRealm", func(t *testing.T) {
Expand All @@ -58,12 +58,12 @@ func TestCmdTrust(t *testing.T) {

t.Run("--realm testRealm", func(t *testing.T) {
err := cmdtest.TestError(t, CmdTrust, "--realm", "testRealm")
require.ErrorContains(t, err, "if any flags in the group [organization realm] are set they must all be set; missing [organization]")
require.ErrorContains(t, err, "if any flags in the group [org realm] are set they must all be set; missing [org]")
})

t.Run("-r testRealm", func(t *testing.T) {
err := cmdtest.TestError(t, CmdTrust, "-r", "testRealm")
require.ErrorContains(t, err, "if any flags in the group [organization realm] are set they must all be set; missing [organization]")
require.ErrorContains(t, err, "if any flags in the group [org realm] are set they must all be set; missing [org]")
})

t.Run("default --trust-stores", func(t *testing.T) {
Expand Down

0 comments on commit e4ca5ed

Please sign in to comment.