Skip to content

Commit

Permalink
Merge pull request #20 from mdb/further-reorg
Browse files Browse the repository at this point in the history
default `--repo` to current repository
  • Loading branch information
mdb committed Nov 15, 2022
2 parents 1ce7c73 + 91fa8bf commit fb5911b
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
@@ -1,6 +1,6 @@
SOURCE=./...
GOFMT_FILES?=$$(find . -type f -name '*.go')
VERSION?=0.0.3
VERSION?=0.0.4

default: build

Expand Down
Binary file added cmd/cmd
Binary file not shown.
12 changes: 10 additions & 2 deletions cmd/main.go
@@ -1,10 +1,12 @@
package main

import (
"fmt"
"os"

"github.com/MakeNowJust/heredoc"
"github.com/mdb/gh-dispatch/dispatch"
"github.com/cli/go-gh"
"github.com/mdb/gh-dispatch/internal/dispatch"
"github.com/spf13/cobra"
)

Expand All @@ -23,8 +25,14 @@ func main() {
Version: version,
}

defaultRepo := ""
currentRepo, _ := gh.CurrentRepository()
if currentRepo != nil {
defaultRepo = fmt.Sprintf("%s/%s", currentRepo.Owner(), currentRepo.Name())
}

// TODO: how to make this required?
rootCmd.PersistentFlags().StringP("repo", "R", "", "The targeted repository's full name (in 'owner/repo' format)")
rootCmd.PersistentFlags().StringP("repo", "R", defaultRepo, "The targeted repository's full name (in 'owner/repo' format)")

repositoryCmd := dispatch.NewCmdRepository()
rootCmd.AddCommand(repositoryCmd)
Expand Down
5 changes: 1 addition & 4 deletions cmd/main_test.go
Expand Up @@ -41,7 +41,7 @@ Available Commands:
Flags:
-h, --help help for gh
-R, --repo string The targeted repository's full name (in 'owner/repo' format)
-R, --repo string The targeted repository's full name (in 'owner/repo' format) (default "mdb/gh-dispatch")
-v, --version version for gh
Use "gh [command] --help" for more information about a command.
Expand Down Expand Up @@ -95,7 +95,6 @@ func TestRepositoryAcceptance(t *testing.T) {
args: []string{
"dispatch",
"repository",
"--repo=mdb/gh-dispatch",
"--event-type=hello",
`--client-payload={"name": "Mike"}`,
"--workflow=Hello",
Expand Down Expand Up @@ -168,7 +167,6 @@ func TestWorkflowAcceptance(t *testing.T) {
args: []string{
"dispatch",
"workflow",
"--repo=mdb/gh-dispatch",
`--inputs={"name": "Mike", "force_fail": "false"}`,
"--workflow=workflow_dispatch.yaml",
},
Expand All @@ -185,7 +183,6 @@ func TestWorkflowAcceptance(t *testing.T) {
args: []string{
"dispatch",
"workflow",
"--repo=mdb/gh-dispatch",
`--inputs={"name": "Mike", "force_fail": "true"}`,
"--workflow=workflow_dispatch.yaml",
},
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit fb5911b

Please sign in to comment.