Skip to content

Commit

Permalink
Allow default path for orb publish command as positional arg
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Scott committed Jul 24, 2018
1 parent 1c600ea commit f70fabd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
9 changes: 6 additions & 3 deletions cmd/orb.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"gopkg.in/yaml.v2"
)

var orbPath string
var orbVersion string
var orbID string

Expand All @@ -42,11 +41,11 @@ func newOrbCommand() *cobra.Command {
}

orbPublishCommand := &cobra.Command{
Use: "publish",
Use: "publish [orb.yml]",
Short: "publish a version of an orb",
RunE: publishOrb,
Args: cobra.MaximumNArgs(1),
}
orbPublishCommand.PersistentFlags().StringVarP(&orbPath, "path", "p", "orb.yml", "path to orb file")
orbPublishCommand.PersistentFlags().StringVarP(&orbVersion, "orb-version", "o", "", "version of orb to publish")
orbPublishCommand.PersistentFlags().StringVarP(&orbID, "orb-id", "i", "", "id of orb to publish")

Expand Down Expand Up @@ -224,6 +223,10 @@ func expandOrb(cmd *cobra.Command, args []string) error {

func publishOrb(cmd *cobra.Command, args []string) error {
ctx := context.Background()
orbPath := defaultOrbPath
if len(args) == 1 {
orbPath = args[0]
}

response, err := api.OrbPublish(ctx, Logger, orbPath, orbVersion, orbID)

Expand Down
12 changes: 1 addition & 11 deletions cmd/orb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ var _ = Describe("Orb integration tests", func() {
})

Describe("when using STDIN", func() {
var (
token string
command *exec.Cmd
)

BeforeEach(func() {
token = "testtoken"
command = exec.Command(pathCLI,
Expand Down Expand Up @@ -111,11 +106,6 @@ var _ = Describe("Orb integration tests", func() {
})

Describe("when using default path", func() {
var (
token string
command *exec.Cmd
)

BeforeEach(func() {
var err error
token = "testtoken"
Expand Down Expand Up @@ -320,7 +310,7 @@ var _ = Describe("Orb integration tests", func() {
"orb", "publish",
"-t", token,
"-e", testServer.URL(),
"-p", orb.Path,
orb.Path,
"--orb-version", "0.0.1",
"--orb-id", "bb604b45-b6b0-4b81-ad80-796f15eddf87",
)
Expand Down

0 comments on commit f70fabd

Please sign in to comment.