X Tutup
Skip to content

Commit 24ebdc2

Browse files
author
Nate Smith
authored
Merge pull request cli#27 from github/fix-repo-branch-flags
Fix global `--repo`, `--current-branch` functionality
2 parents 398bd27 + c82e383 commit 24ebdc2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

command/root.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ var (
1717
func init() {
1818
RootCmd.PersistentFlags().StringVarP(&currentRepo, "repo", "R", "", "current GitHub repository")
1919
RootCmd.PersistentFlags().StringVarP(&currentBranch, "current-branch", "B", "", "current git branch")
20+
}
2021

22+
func initContext() {
2123
ctx := context.InitDefaultContext()
2224
ctx.SetBranch(currentBranch)
2325
repo := currentRepo
@@ -35,6 +37,9 @@ var RootCmd = &cobra.Command{
3537
Short: "GitHub CLI",
3638
Long: `Do things with GitHub from your terminal`,
3739
Args: cobra.MinimumNArgs(1),
40+
PersistentPreRun: func(cmd *cobra.Command, args []string) {
41+
initContext()
42+
},
3843
Run: func(cmd *cobra.Command, args []string) {
3944
fmt.Println("root")
4045
},

0 commit comments

Comments
 (0)
X Tutup