Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Cobra for the Command Line Interface #321

Merged
merged 1 commit into from
Oct 8, 2020
Merged

Conversation

lonnblad
Copy link
Member

@lonnblad lonnblad commented Jun 27, 2020

  • Added the CLI framework Cobra
  • Broke down the godog CLI into subcommands:
    • build
    • help
    • run
    • version

> godog help
godog help

> godog help run
godog help run

> godog --help (godog v0.10.0)
godog

@lonnblad lonnblad force-pushed the new-flag-pkg branch 2 times, most recently from 2a1860c to 8ef3108 Compare June 27, 2020 15:23
@codecov
Copy link

codecov bot commented Jun 27, 2020

Codecov Report

Merging #321 into master will increase coverage by 0.09%.
The diff coverage is 84.61%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #321      +/-   ##
==========================================
+ Coverage   79.93%   80.03%   +0.09%     
==========================================
  Files          23       25       +2     
  Lines        2218     2254      +36     
==========================================
+ Hits         1773     1804      +31     
- Misses        342      347       +5     
  Partials      103      103              
Impacted Files Coverage Δ
flags_deprecated.go 93.80% <ø> (ø)
internal/builder/builder.go 62.67% <ø> (ø)
run.go 81.88% <0.00%> (ø)
flags_v0110.go 50.00% <50.00%> (ø)
internal/flags/flags.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e6223ba...722d97b. Read the comment docs.

@lonnblad lonnblad force-pushed the new-flag-pkg branch 7 times, most recently from 17623ff to 34e2636 Compare July 2, 2020 06:51
@aslakhellesoy
Copy link
Contributor

What's the motivation of having a command-based CLI as opposed to an option-based one?

@lonnblad
Copy link
Member Author

lonnblad commented Jul 5, 2020

What's the motivation of having a command-based CLI as opposed to an option-based one?

@aslakhellesoy
Separation of concern and structure mainly.

If you now would execute > godog --format progress vs. > godog --format progress --output godog.test.
A binary would be created in the second example, while in the first example, a binary would first be created and then executed, running the testcases with the progress formatter.
A detail is that, if you after the second example, would execute > ./godog.test, you would not get the progress formatter, because the binary requires its own set of options, so you would have to execute it like: > ./godog.test --format progress.

There have also been previous discussions here to build a function that checks the gherkin and the registered step definitions, which would fit well into the sub-command structure as well, maybe as an fmt or validate command.

When starting out with godog and gherkin, I would have liked to see something like > godog init, which would have created a basic godog structure to get people started. The getting started document would then more or less be:

Initialize a go module for the godog example:
  > go mod init godog-example
Install godog:
  > go get github.com/cucumber/godog/cmd/[email protected]
Create a simple example:
  > godog init --example
Run the example:
  > godog run

For people that are used to using the go binary, there are two different solutions that solve a similar problem:
> go build main.go vs > go run main.go, where build builds a binary from main.go and run both builds and then executes it.
> go test . vs go test -c ., where the first builds and executes the tests, while -c builds a binary.

@lonnblad
Copy link
Member Author

lonnblad commented Jul 7, 2020

@aslakhellesoy what do you think?

Copy link
Contributor

@titouanfreville titouanfreville left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this feature 👍

@lonnblad lonnblad merged commit 66793de into master Oct 8, 2020
@mattwynne mattwynne deleted the new-flag-pkg branch April 30, 2022 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants