Skip to content

Commit 38f1d17

Browse files
committed
close #67 help and version command outside repo
1 parent 03fd4f9 commit 38f1d17

30 files changed

+158
-70
lines changed

cmd/auth.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cmd
22

33
import (
44
"fmt"
5+
56
"github.com/praqma/git-phlow/phlow"
67
"github.com/praqma/git-phlow/ui"
78
"github.com/spf13/cobra"

cmd/cleanup.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cmd
33
import (
44
"fmt"
55

6+
"github.com/praqma/git-phlow/cmdcheck"
67
"github.com/praqma/git-phlow/githandler"
78
"github.com/praqma/git-phlow/options"
89
"github.com/praqma/git-phlow/phlow"
@@ -19,6 +20,9 @@ var cleanCmd = &cobra.Command{
1920
%s removes all branches prefixed with 'delivered/'.
2021
It deletes safely by running 'git branch -d'. By default, both local and remote branches are deleted.
2122
`, ui.Bold("phlow clean")),
23+
PreRun: func(cmd *cobra.Command, args []string) {
24+
checks.IsRepository()
25+
},
2226
Run: func(cmd *cobra.Command, args []string) {
2327
defaultBranch, _ := plugins.GitHub.Branch.Default()
2428
remote := githandler.ConfigBranchRemote(defaultBranch)

cmd/deliver.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"os"
66

7+
"github.com/praqma/git-phlow/cmdcheck"
78
"github.com/praqma/git-phlow/options"
89
"github.com/praqma/git-phlow/phlow"
910
"github.com/praqma/git-phlow/plugins"
@@ -25,10 +26,12 @@ so integration services supporting the workflow can pick up the changes.
2526
if you deliver with local, the branch will be merged with your default branch,
2627
and pushed to your "remote default branch" and prefixed with "/delivered"
2728
`,
29+
PreRun: func(cmd *cobra.Command, args []string) {
30+
checks.IsRepository()
31+
},
2832
Run: func(cmd *cobra.Command, args []string) {
2933

3034
defaultBranch, _ := plugins.GitHub.Branch.Default()
31-
3235
//Run tests before deliver
3336
if len(args) > 0 {
3437
if err := phlow.TestDeliver(args); err != nil {
@@ -44,10 +47,8 @@ and pushed to your "remote default branch" and prefixed with "/delivered"
4447
phlow.LocalDeliver(defaultBranch)
4548
return
4649
}
47-
4850
//Deliver with ready branch
4951
phlow.Deliver(defaultBranch)
50-
5152
},
5253
}
5354

cmd/integrate.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cmd
33
import (
44
"fmt"
55

6+
"github.com/praqma/git-phlow/cmdcheck"
67
"github.com/praqma/git-phlow/phlow"
78
"github.com/praqma/git-phlow/plugins"
89
"github.com/praqma/git-phlow/ui"
@@ -17,6 +18,10 @@ var integrateCmd = &cobra.Command{
1718
%s delivers the changes in an agent version. The current branch if will be merged into the default branch
1819
with your default branch and pushed to the remote.
1920
`, ui.Bold("integrate")),
21+
PreRun: func(cmd *cobra.Command, args []string) {
22+
checks.IsRepository()
23+
checks.IsAuthenticated()
24+
},
2025
Run: func(cmd *cobra.Command, args []string) {
2126

2227
defaultBranch, err := plugins.GitHub.Branch.Default()

cmd/issues.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cmd
22

33
import (
4+
"github.com/praqma/git-phlow/cmdcheck"
45
"github.com/praqma/git-phlow/options"
56
"github.com/praqma/git-phlow/phlow"
67
"github.com/spf13/cobra"
@@ -13,6 +14,9 @@ var issueCmd = &cobra.Command{
1314
Long: `
1415
List all the open issues on GitHub with it's ID. Helps you locate what needs to be worked on
1516
`,
17+
PreRun: func(cmd *cobra.Command, args []string) {
18+
checks.IsRepository()
19+
},
1620
Run: func(cmd *cobra.Command, args []string) {
1721
phlow.IssueList()
1822
},

cmd/root.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55
"os"
66

7-
"github.com/praqma/git-phlow/githandler"
87
"github.com/praqma/git-phlow/options"
98
"github.com/spf13/cobra"
109
)
@@ -17,13 +16,6 @@ var RootCmd = &cobra.Command{
1716
git-phlow is a git extension that provides an extra set of commands, enabling you to:
1817
workon, deliver and create new tasks.
1918
`,
20-
PersistentPreRun: func(cmd *cobra.Command, args []string) {
21-
//Move as before check
22-
if err := githandler.Status(); err != nil {
23-
fmt.Fprintln(os.Stdout, err)
24-
os.Exit(0)
25-
}
26-
},
2719
Run: func(cmd *cobra.Command, args []string) {
2820
if options.GlobalFlagVersion != false {
2921
fmt.Println("phlow specification")
@@ -34,7 +26,6 @@ workon, deliver and create new tasks.
3426
}
3527

3628
fmt.Println(cmd.UsageString())
37-
3829
},
3930
}
4031

cmd/upnext.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cmd
33
import (
44
"fmt"
55

6+
"github.com/praqma/git-phlow/cmdcheck"
67
"github.com/praqma/git-phlow/githandler"
78
"github.com/praqma/git-phlow/options"
89
"github.com/praqma/git-phlow/phlow"
@@ -19,7 +20,9 @@ var upNextCmd = &cobra.Command{
1920
%s gets the next branch ready for integration based on the branch creation time.
2021
The branch created first, is the branch thats up next.
2122
`, ui.Bold("upnext")),
22-
23+
PreRun: func(cmd *cobra.Command, args []string) {
24+
checks.IsRepository()
25+
},
2326
Run: func(cmd *cobra.Command, args []string) {
2427

2528
defaultBranch, _ := plugins.GitHub.Branch.Default()

cmd/web.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ package cmd
33
import (
44
"fmt"
55

6-
"github.com/spf13/cobra"
7-
"github.com/praqma/git-phlow/phlow"
8-
"strconv"
96
"os"
7+
"strconv"
8+
9+
"github.com/praqma/git-phlow/phlow"
10+
"github.com/spf13/cobra"
11+
12+
"github.com/praqma/git-phlow/cmdcheck"
1013
)
1114

1215
// webCmd represents the web command
@@ -18,8 +21,10 @@ web opens a github issue or githubs issue list based on it's arguments'
1821
If no argument is passed, it tries to locate an issue on the current checked out branch,
1922
if that fails it will simply open GitHubs issue list in your default browser
2023
`,
24+
PreRun: func(cmd *cobra.Command, args []string) {
25+
checks.IsRepository()
26+
},
2127
Run: func(cmd *cobra.Command, args []string) {
22-
2328
if len(args) > 0 {
2429
if val, err := strconv.Atoi(args[0]); err == nil {
2530
phlow.Web(val)

cmd/workon.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"os"
66
"strconv"
77

8+
"github.com/praqma/git-phlow/cmdcheck"
89
"github.com/praqma/git-phlow/phlow"
910
"github.com/praqma/git-phlow/ui"
1011
"github.com/spf13/cobra"
@@ -20,12 +21,16 @@ A branch will be created from your remote default branch and named after the tit
2021
of the issue eg. branch => "42-calculate-meaning-of-life".
2122
From here you the work can start, and when finished run phlow wrapup.
2223
`, ui.Bold("workon")),
24+
PreRun: func(cmd *cobra.Command, args []string) {
25+
checks.IsRepository()
26+
checks.IsAuthenticated()
27+
},
2328
Run: func(cmd *cobra.Command, args []string) {
2429

2530
if len(args) > 0 {
2631
issue, err := strconv.Atoi(args[0])
2732
if err != nil {
28-
fmt.Fprintf(os.Stdout, "Whoops \nYour argument: %s, is not a 'number' I only feast on numbers \n", args[0])
33+
fmt.Fprintf(os.Stdout, "Whoops \nYour argument: %s, is not a number I only want numbers \n", args[0])
2934
os.Exit(0)
3035
}
3136

cmd/wrapup.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cmd
33
import (
44
"fmt"
55

6+
"github.com/praqma/git-phlow/cmdcheck"
67
"github.com/praqma/git-phlow/options"
78
"github.com/praqma/git-phlow/phlow"
89
"github.com/praqma/git-phlow/ui"
@@ -13,10 +14,12 @@ var wrapupCmd = &cobra.Command{
1314
Use: "wrapup",
1415
Short: "add changes and make auto-commit",
1516
Long: fmt.Sprintf(`
16-
%s adds all your work from the working area to the index, and makes an automatic close # commit,
17+
%s adds all your work from the working area to the index, and makes an automatic close # commit,
1718
which closes an issue on github eg. commit message => "close #42 fetch meaning of life"
1819
`, ui.Bold("wrapup")),
19-
20+
PreRun: func(cmd *cobra.Command, args []string) {
21+
checks.IsRepository()
22+
},
2023
Run: func(cmd *cobra.Command, args []string) {
2124
phlow.WrapUp()
2225
},

0 commit comments

Comments
 (0)