From 7a511f9a13f3d1064fd11c9146e6b21cb961a8b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Wed, 17 Oct 2018 20:38:10 +0200 Subject: [PATCH] commands: don't load the repo for commands that don't need it fix #67 --- commands/add.go | 7 ++++--- commands/bridge.go | 9 +++++---- commands/bridge_configure.go | 7 ++++--- commands/bridge_pull.go | 7 ++++--- commands/bridge_rm.go | 9 +++++---- commands/comment.go | 7 ++++--- commands/comment_add.go | 7 ++++--- commands/deselect.go | 3 ++- commands/label.go | 7 ++++--- commands/label_add.go | 7 ++++--- commands/label_rm.go | 7 ++++--- commands/ls-labels.go | 3 ++- commands/ls.go | 3 ++- commands/pull.go | 7 ++++--- commands/push.go | 7 ++++--- commands/root.go | 4 ---- commands/select.go | 3 ++- commands/show.go | 7 ++++--- commands/status.go | 7 ++++--- commands/status_close.go | 7 ++++--- commands/status_open.go | 7 ++++--- commands/termui.go | 7 ++++--- commands/title.go | 7 ++++--- commands/title_edit.go | 7 ++++--- commands/webui.go | 7 ++++--- 25 files changed, 90 insertions(+), 70 deletions(-) diff --git a/commands/add.go b/commands/add.go index 944f0a99a29c9a3df15bfbe3a96e1daf5f36c55d..081c99f13b4aa1fc2c1f3c647fb2ec70eb956bf7 100644 --- a/commands/add.go +++ b/commands/add.go @@ -53,9 +53,10 @@ func runAddBug(cmd *cobra.Command, args []string) error { } var addCmd = &cobra.Command{ - Use: "add", - Short: "Create a new bug", - RunE: runAddBug, + Use: "add", + Short: "Create a new bug", + PreRunE: loadRepo, + RunE: runAddBug, } func init() { diff --git a/commands/bridge.go b/commands/bridge.go index 5dc4e744db0da452d124962685eece47e81100c4..4576cd0aac1c5537157300aeeab7e4e97e9d007d 100644 --- a/commands/bridge.go +++ b/commands/bridge.go @@ -28,10 +28,11 @@ func runBridge(cmd *cobra.Command, args []string) error { } var bridgeCmd = &cobra.Command{ - Use: "bridge", - Short: "Configure and use bridges to other bug trackers", - RunE: runBridge, - Args: cobra.NoArgs, + Use: "bridge", + Short: "Configure and use bridges to other bug trackers", + PreRunE: loadRepo, + RunE: runBridge, + Args: cobra.NoArgs, } func init() { diff --git a/commands/bridge_configure.go b/commands/bridge_configure.go index 4329b54cfe5f991fc9bd659581c09585e1a7f3a0..ed18cae9df2f9707a1f74282f0a1ee2cebfb56a9 100644 --- a/commands/bridge_configure.go +++ b/commands/bridge_configure.go @@ -88,9 +88,10 @@ func promptName() (string, error) { } var bridgeConfigureCmd = &cobra.Command{ - Use: "configure", - Short: "Configure a new bridge", - RunE: runBridgeConfigure, + Use: "configure", + Short: "Configure a new bridge", + PreRunE: loadRepo, + RunE: runBridgeConfigure, } func init() { diff --git a/commands/bridge_pull.go b/commands/bridge_pull.go index 521f2d9c2616ab2961a952daaea7d77bef11c850..a90a533f03b088f52694829664e71527ea692d55 100644 --- a/commands/bridge_pull.go +++ b/commands/bridge_pull.go @@ -35,9 +35,10 @@ func runBridgePull(cmd *cobra.Command, args []string) error { } var bridgePullCmd = &cobra.Command{ - Use: "pull []", - Short: "Pull updates", - RunE: runBridgePull, + Use: "pull []", + Short: "Pull updates", + PreRunE: loadRepo, + RunE: runBridgePull, } func init() { diff --git a/commands/bridge_rm.go b/commands/bridge_rm.go index acde9da54339ff7cf8a8d97100e889e60f921db8..2ebc17a7a47fce533a3db6f0940173ef3d1112b0 100644 --- a/commands/bridge_rm.go +++ b/commands/bridge_rm.go @@ -22,10 +22,11 @@ func runBridgeRm(cmd *cobra.Command, args []string) error { } var bridgeRmCmd = &cobra.Command{ - Use: "rm name ", - Short: "Delete a configured bridge", - RunE: runBridgeRm, - Args: cobra.ExactArgs(1), + Use: "rm name ", + Short: "Delete a configured bridge", + PreRunE: loadRepo, + RunE: runBridgeRm, + Args: cobra.ExactArgs(1), } func init() { diff --git a/commands/comment.go b/commands/comment.go index c05fd25526442653943328950111a3e9bb6e22dd..fc4b6a6b24d566db65ce874aedcea2f2d69a57c2 100644 --- a/commands/comment.go +++ b/commands/comment.go @@ -43,9 +43,10 @@ func commentsTextOutput(comments []bug.Comment) { } var commentCmd = &cobra.Command{ - Use: "comment []", - Short: "Display or add comments", - RunE: runComment, + Use: "comment []", + Short: "Display or add comments", + PreRunE: loadRepo, + RunE: runComment, } func init() { diff --git a/commands/comment_add.go b/commands/comment_add.go index 8736f9c27fa92ffcb6428691ed23bc00263f69fa..6ee3fc15068c9e09ddd1b62ddc4271eda5e9f62b 100644 --- a/commands/comment_add.go +++ b/commands/comment_add.go @@ -53,9 +53,10 @@ func runCommentAdd(cmd *cobra.Command, args []string) error { } var commentAddCmd = &cobra.Command{ - Use: "add []", - Short: "Add a new comment", - RunE: runCommentAdd, + Use: "add []", + Short: "Add a new comment", + PreRunE: loadRepo, + RunE: runCommentAdd, } func init() { diff --git a/commands/deselect.go b/commands/deselect.go index f2907c70512f0920e5445becc67b35a9654e31e5..a2e8d30d65057c6605c1478fcbcf74e555f5b829 100644 --- a/commands/deselect.go +++ b/commands/deselect.go @@ -29,7 +29,8 @@ git bug comment git bug status git bug deselect `, - RunE: runDeselect, + PreRunE: loadRepo, + RunE: runDeselect, } func init() { diff --git a/commands/label.go b/commands/label.go index fd958d688d394fca84c50127e25b410ed6d39e04..0221701ca2ac62a0531d2a250b9943c0967b7851 100644 --- a/commands/label.go +++ b/commands/label.go @@ -30,9 +30,10 @@ func runLabel(cmd *cobra.Command, args []string) error { } var labelCmd = &cobra.Command{ - Use: "label []", - Short: "Display, add or remove labels", - RunE: runLabel, + Use: "label []", + Short: "Display, add or remove labels", + PreRunE: loadRepo, + RunE: runLabel, } func init() { diff --git a/commands/label_add.go b/commands/label_add.go index 06c4e6c5429f8ceb46b537c6be7d2cca11a6efd2..278d64721e977f2611af828d7ce7e1d56d1248de 100644 --- a/commands/label_add.go +++ b/commands/label_add.go @@ -34,9 +34,10 @@ func runLabelAdd(cmd *cobra.Command, args []string) error { } var labelAddCmd = &cobra.Command{ - Use: "add []