Merge pull request #671 from MichaelMure/close-on-error

commands: proper backend close on RunE error
This commit is contained in:
Michael Muré 2021-05-10 11:14:26 +02:00 committed by GitHub
commit 13d9632fb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 174 additions and 200 deletions

View File

@ -19,13 +19,12 @@ func newAddCommand() *cobra.Command {
options := addOptions{} options := addOptions{}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "add", Use: "add",
Short: "Create a new bug.", Short: "Create a new bug.",
PreRunE: loadBackendEnsureUser(env), PreRunE: loadBackendEnsureUser(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runAdd(env, options) return runAdd(env, options)
}, }),
} }
flags := cmd.Flags() flags := cmd.Flags()

View File

@ -10,13 +10,12 @@ func newBridgeCommand() *cobra.Command {
env := newEnv() env := newEnv()
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "bridge", Use: "bridge",
Short: "Configure and use bridges to other bug trackers.", Short: "Configure and use bridges to other bug trackers.",
PreRunE: loadBackend(env), PreRunE: loadBackend(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runBridge(env) return runBridge(env)
}, }),
Args: cobra.NoArgs, Args: cobra.NoArgs,
} }

View File

@ -16,13 +16,12 @@ func newBridgeAuthCommand() *cobra.Command {
env := newEnv() env := newEnv()
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "auth", Use: "auth",
Short: "List all known bridge authentication credentials.", Short: "List all known bridge authentication credentials.",
PreRunE: loadBackend(env), PreRunE: loadBackend(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runBridgeAuth(env) return runBridgeAuth(env)
}, }),
Args: cobra.NoArgs, Args: cobra.NoArgs,
} }

View File

@ -27,13 +27,12 @@ func newBridgeAuthAddTokenCommand() *cobra.Command {
options := bridgeAuthAddTokenOptions{} options := bridgeAuthAddTokenOptions{}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "add-token [TOKEN]", Use: "add-token [TOKEN]",
Short: "Store a new token", Short: "Store a new token",
PreRunE: loadBackendEnsureUser(env), PreRunE: loadBackendEnsureUser(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runBridgeAuthAddToken(env, options, args) return runBridgeAuthAddToken(env, options, args)
}, }),
Args: cobra.MaximumNArgs(1), Args: cobra.MaximumNArgs(1),
} }

View File

@ -15,13 +15,12 @@ func newBridgeAuthShow() *cobra.Command {
env := newEnv() env := newEnv()
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "show", Use: "show",
Short: "Display an authentication credential.", Short: "Display an authentication credential.",
PreRunE: loadBackend(env), PreRunE: loadBackend(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runBridgeAuthShow(env, args) return runBridgeAuthShow(env, args)
}, }),
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
} }

View File

@ -85,11 +85,10 @@ git bug bridge configure \
--target=github \ --target=github \
--url=https://github.com/michaelmure/git-bug \ --url=https://github.com/michaelmure/git-bug \
--token=$(TOKEN)`, --token=$(TOKEN)`,
PreRunE: loadBackend(env), PreRunE: loadBackend(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runBridgeConfigure(env, options) return runBridgeConfigure(env, options)
}, }),
} }
flags := cmd.Flags() flags := cmd.Flags()

View File

@ -26,13 +26,12 @@ func newBridgePullCommand() *cobra.Command {
options := bridgePullOptions{} options := bridgePullOptions{}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "pull [NAME]", Use: "pull [NAME]",
Short: "Pull updates.", Short: "Pull updates.",
PreRunE: loadBackend(env), PreRunE: loadBackend(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runBridgePull(env, options, args) return runBridgePull(env, options, args)
}, }),
Args: cobra.MaximumNArgs(1), Args: cobra.MaximumNArgs(1),
} }

View File

@ -17,13 +17,12 @@ func newBridgePushCommand() *cobra.Command {
env := newEnv() env := newEnv()
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "push [NAME]", Use: "push [NAME]",
Short: "Push updates.", Short: "Push updates.",
PreRunE: loadBackendEnsureUser(env), PreRunE: loadBackendEnsureUser(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runBridgePush(env, args) return runBridgePush(env, args)
}, }),
Args: cobra.MaximumNArgs(1), Args: cobra.MaximumNArgs(1),
} }

View File

@ -10,13 +10,12 @@ func newBridgeRm() *cobra.Command {
env := newEnv() env := newEnv()
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "rm NAME", Use: "rm NAME",
Short: "Delete a configured bridge.", Short: "Delete a configured bridge.",
PreRunE: loadBackend(env), PreRunE: loadBackend(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runBridgeRm(env, args) return runBridgeRm(env, args)
}, }),
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
} }

View File

@ -12,13 +12,12 @@ func newCommentCommand() *cobra.Command {
env := newEnv() env := newEnv()
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "comment [ID]", Use: "comment [ID]",
Short: "Display or add comments to a bug.", Short: "Display or add comments to a bug.",
PreRunE: loadBackend(env), PreRunE: loadBackend(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runComment(env, args) return runComment(env, args)
}, }),
} }
cmd.AddCommand(newCommentAddCommand()) cmd.AddCommand(newCommentAddCommand())

View File

@ -19,13 +19,12 @@ func newCommentAddCommand() *cobra.Command {
options := commentAddOptions{} options := commentAddOptions{}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "add [ID]", Use: "add [ID]",
Short: "Add a new comment to a bug.", Short: "Add a new comment to a bug.",
PreRunE: loadBackendEnsureUser(env), PreRunE: loadBackendEnsureUser(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runCommentAdd(env, options, args) return runCommentAdd(env, options, args)
}, }),
} }
flags := cmd.Flags() flags := cmd.Flags()

View File

@ -17,14 +17,13 @@ func newCommentEditCommand() *cobra.Command {
options := commentEditOptions{} options := commentEditOptions{}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "edit [COMMENT_ID]", Use: "edit [COMMENT_ID]",
Short: "Edit an existing comment on a bug.", Short: "Edit an existing comment on a bug.",
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
PreRunE: loadBackendEnsureUser(env), PreRunE: loadBackendEnsureUser(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runCommentEdit(env, options, args) return runCommentEdit(env, options, args)
}, }),
} }
flags := cmd.Flags() flags := cmd.Flags()

View File

@ -17,11 +17,10 @@ git bug comment
git bug status git bug status
git bug deselect git bug deselect
`, `,
PreRunE: loadBackend(env), PreRunE: loadBackend(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runDeselect(env) return runDeselect(env)
}, }),
} }
return cmd return cmd

View File

@ -136,15 +136,23 @@ func loadBackendEnsureUser(env *Env) func(*cobra.Command, []string) error {
} }
} }
// closeBackend is a post-run function that will close the backend properly // closeBackend is a wrapper for a RunE function that will close the backend properly
// if it has been opened. // if it has been opened.
func closeBackend(env *Env) func(*cobra.Command, []string) error { // This wrapper style is necessary because a Cobra PostE function does not run if RunE return an error.
func closeBackend(env *Env, runE func(cmd *cobra.Command, args []string) error) func(*cobra.Command, []string) error {
return func(cmd *cobra.Command, args []string) error { return func(cmd *cobra.Command, args []string) error {
errRun := runE(cmd, args)
if env.backend == nil { if env.backend == nil {
return nil return nil
} }
err := env.backend.Close() err := env.backend.Close()
env.backend = nil env.backend = nil
// prioritize the RunE error
if errRun != nil {
return errRun
}
return err return err
} }
} }

View File

@ -10,13 +10,12 @@ func newLabelCommand() *cobra.Command {
env := newEnv() env := newEnv()
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "label [ID]", Use: "label [ID]",
Short: "Display, add or remove labels to/from a bug.", Short: "Display, add or remove labels to/from a bug.",
PreRunE: loadBackend(env), PreRunE: loadBackend(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runLabel(env, args) return runLabel(env, args)
}, }),
} }
cmd.AddCommand(newLabelAddCommand()) cmd.AddCommand(newLabelAddCommand())

View File

@ -11,13 +11,12 @@ func newLabelAddCommand() *cobra.Command {
env := newEnv() env := newEnv()
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "add [ID] LABEL...", Use: "add [ID] LABEL...",
Short: "Add a label to a bug.", Short: "Add a label to a bug.",
PreRunE: loadBackendEnsureUser(env), PreRunE: loadBackendEnsureUser(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runLabelAdd(env, args) return runLabelAdd(env, args)
}, }),
} }
return cmd return cmd

View File

@ -11,13 +11,12 @@ func newLabelRmCommand() *cobra.Command {
env := newEnv() env := newEnv()
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "rm [ID] LABEL...", Use: "rm [ID] LABEL...",
Short: "Remove a label from a bug.", Short: "Remove a label from a bug.",
PreRunE: loadBackend(env), PreRunE: loadBackend(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runLabelRm(env, args) return runLabelRm(env, args)
}, }),
} }
return cmd return cmd

View File

@ -8,13 +8,12 @@ func newLsIdCommand() *cobra.Command {
env := newEnv() env := newEnv()
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "ls-id [PREFIX]", Use: "ls-id [PREFIX]",
Short: "List bug identifiers.", Short: "List bug identifiers.",
PreRunE: loadBackend(env), PreRunE: loadBackend(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runLsId(env, args) return runLsId(env, args)
}, }),
} }
return cmd return cmd

View File

@ -13,11 +13,10 @@ func newLsLabelCommand() *cobra.Command {
Long: `List valid labels. Long: `List valid labels.
Note: in the future, a proper label policy could be implemented where valid labels are defined in a configuration file. Until that, the default behavior is to return the list of labels already used.`, Note: in the future, a proper label policy could be implemented where valid labels are defined in a configuration file. Until that, the default behavior is to return the list of labels already used.`,
PreRunE: loadBackend(env), PreRunE: loadBackend(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runLsLabel(env) return runLsLabel(env)
}, }),
} }
return cmd return cmd

View File

@ -52,11 +52,10 @@ git bug ls "foo bar" baz
Use queries, flags, and full text search: Use queries, flags, and full text search:
git bug ls status:open --by creation "foo bar" baz git bug ls status:open --by creation "foo bar" baz
`, `,
PreRunE: loadBackend(env), PreRunE: loadBackend(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runLs(env, options, args) return runLs(env, options, args)
}, }),
} }
flags := cmd.Flags() flags := cmd.Flags()

View File

@ -12,13 +12,12 @@ func newPullCommand() *cobra.Command {
env := newEnv() env := newEnv()
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "pull [REMOTE]", Use: "pull [REMOTE]",
Short: "Pull bugs update from a git remote.", Short: "Pull bugs update from a git remote.",
PreRunE: loadBackend(env), PreRunE: loadBackend(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runPull(env, args) return runPull(env, args)
}, }),
} }
return cmd return cmd

View File

@ -10,13 +10,12 @@ func newPushCommand() *cobra.Command {
env := newEnv() env := newEnv()
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "push [REMOTE]", Use: "push [REMOTE]",
Short: "Push bugs update to a git remote.", Short: "Push bugs update to a git remote.",
PreRunE: loadBackend(env), PreRunE: loadBackend(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runPush(env, args) return runPush(env, args)
}, }),
} }
return cmd return cmd

View File

@ -10,14 +10,13 @@ func newRmCommand() *cobra.Command {
env := newEnv() env := newEnv()
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "rm ID", Use: "rm ID",
Short: "Remove an existing bug.", Short: "Remove an existing bug.",
Long: "Remove an existing bug in the local repository. Note removing bugs that were imported from bridges will not remove the bug on the remote, and will only remove the local copy of the bug.", Long: "Remove an existing bug in the local repository. Note removing bugs that were imported from bridges will not remove the bug on the remote, and will only remove the local copy of the bug.",
PreRunE: loadBackendEnsureUser(env), PreRunE: loadBackendEnsureUser(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runRm(env, args) return runRm(env, args)
}, }),
} }
flags := cmd.Flags() flags := cmd.Flags()

View File

@ -27,11 +27,10 @@ instead of
The complementary command is "git bug deselect" performing the opposite operation. The complementary command is "git bug deselect" performing the opposite operation.
`, `,
PreRunE: loadBackend(env), PreRunE: loadBackend(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runSelect(env, args) return runSelect(env, args)
}, }),
} }
return cmd return cmd

View File

@ -23,13 +23,12 @@ func newShowCommand() *cobra.Command {
options := showOptions{} options := showOptions{}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "show [ID]", Use: "show [ID]",
Short: "Display the details of a bug.", Short: "Display the details of a bug.",
PreRunE: loadBackend(env), PreRunE: loadBackend(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runShow(env, options, args) return runShow(env, options, args)
}, }),
} }
flags := cmd.Flags() flags := cmd.Flags()

View File

@ -9,13 +9,12 @@ func newStatusCommand() *cobra.Command {
env := newEnv() env := newEnv()
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "status [ID]", Use: "status [ID]",
Short: "Display or change a bug status.", Short: "Display or change a bug status.",
PreRunE: loadBackend(env), PreRunE: loadBackend(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runStatus(env, args) return runStatus(env, args)
}, }),
} }
cmd.AddCommand(newStatusCloseCommand()) cmd.AddCommand(newStatusCloseCommand())

View File

@ -9,13 +9,12 @@ func newStatusCloseCommand() *cobra.Command {
env := newEnv() env := newEnv()
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "close [ID]", Use: "close [ID]",
Short: "Mark a bug as closed.", Short: "Mark a bug as closed.",
PreRunE: loadBackendEnsureUser(env), PreRunE: loadBackendEnsureUser(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runStatusClose(env, args) return runStatusClose(env, args)
}, }),
} }
return cmd return cmd

View File

@ -9,13 +9,12 @@ func newStatusOpenCommand() *cobra.Command {
env := newEnv() env := newEnv()
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "open [ID]", Use: "open [ID]",
Short: "Mark a bug as open.", Short: "Mark a bug as open.",
PreRunE: loadBackendEnsureUser(env), PreRunE: loadBackendEnsureUser(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runStatusOpen(env, args) return runStatusOpen(env, args)
}, }),
} }
return cmd return cmd

View File

@ -10,14 +10,13 @@ func newTermUICommand() *cobra.Command {
env := newEnv() env := newEnv()
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "termui", Use: "termui",
Aliases: []string{"tui"}, Aliases: []string{"tui"},
Short: "Launch the terminal UI.", Short: "Launch the terminal UI.",
PreRunE: loadBackendEnsureUser(env), PreRunE: loadBackendEnsureUser(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runTermUI(env) return runTermUI(env)
}, }),
} }
return cmd return cmd

View File

@ -9,13 +9,12 @@ func newTitleCommand() *cobra.Command {
env := newEnv() env := newEnv()
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "title [ID]", Use: "title [ID]",
Short: "Display or change a title of a bug.", Short: "Display or change a title of a bug.",
PreRunE: loadBackend(env), PreRunE: loadBackend(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runTitle(env, args) return runTitle(env, args)
}, }),
} }
cmd.AddCommand(newTitleEditCommand()) cmd.AddCommand(newTitleEditCommand())

View File

@ -18,13 +18,12 @@ func newTitleEditCommand() *cobra.Command {
options := titleEditOptions{} options := titleEditOptions{}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "edit [ID]", Use: "edit [ID]",
Short: "Edit a title of a bug.", Short: "Edit a title of a bug.",
PreRunE: loadBackendEnsureUser(env), PreRunE: loadBackendEnsureUser(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runTitleEdit(env, options, args) return runTitleEdit(env, options, args)
}, }),
} }
flags := cmd.Flags() flags := cmd.Flags()

View File

@ -18,13 +18,12 @@ func newUserCommand() *cobra.Command {
options := userOptions{} options := userOptions{}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "user [USER-ID]", Use: "user [USER-ID]",
Short: "Display or change the user identity.", Short: "Display or change the user identity.",
PreRunE: loadBackendEnsureUser(env), PreRunE: loadBackendEnsureUser(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runUser(env, options, args) return runUser(env, options, args)
}, }),
} }
cmd.AddCommand(newUserAdoptCommand()) cmd.AddCommand(newUserAdoptCommand())

View File

@ -8,14 +8,13 @@ func newUserAdoptCommand() *cobra.Command {
env := newEnv() env := newEnv()
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "adopt USER-ID", Use: "adopt USER-ID",
Short: "Adopt an existing identity as your own.", Short: "Adopt an existing identity as your own.",
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
PreRunE: loadBackend(env), PreRunE: loadBackend(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runUserAdopt(env, args) return runUserAdopt(env, args)
}, }),
} }
return cmd return cmd

View File

@ -18,13 +18,12 @@ func newUserCreateCommand() *cobra.Command {
options := createUserOptions{} options := createUserOptions{}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "create", Use: "create",
Short: "Create a new identity.", Short: "Create a new identity.",
PreRunE: loadBackend(env), PreRunE: loadBackend(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runUserCreate(env, options) return runUserCreate(env, options)
}, }),
} }
flags := cmd.Flags() flags := cmd.Flags()

View File

@ -19,13 +19,12 @@ func newUserLsCommand() *cobra.Command {
options := userLsOptions{} options := userLsOptions{}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "ls", Use: "ls",
Short: "List identities.", Short: "List identities.",
PreRunE: loadBackend(env), PreRunE: loadBackend(env),
PostRunE: closeBackend(env), RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
return runUserLs(env, options) return runUserLs(env, options)
}, }),
} }
flags := cmd.Flags() flags := cmd.Flags()