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

Add CLI support to the project #12

Merged
merged 1 commit into from
Sep 8, 2019
Merged

Add CLI support to the project #12

merged 1 commit into from
Sep 8, 2019

Conversation

Cruikshanks
Copy link
Member

A nice feature to add (plus it gave us some exposure to a couple of new cool tools) was to allow users of the demo app to change the port used by Sinatra. It defaults to 4567, and it's unlikely someone would already be running something on that already.

But just in case we've added the ability to specify a custom port in the app. We've done this by adding Thor as a dependency. Thor is a toolkit for building powerful command-line interfaces. In our case it allowed us to

  • add a default command
  • add a description for that command
  • add help on how to use the command
  • add support for a custom argument (--port)
  • add an alias for the custom argument (-p)
  • add help on how to the custom argument

This meant some refactoring in the project, mainly dropping the Run class in favour of a CLI class that inherits from Thor.

The second cool tool we added was Aruba. Aruba allows you to test command-line applications with Cucumber-Ruby, RSpec or Minitest. It essentially runs your app in a separate process but still allows you to make assertions against the behaviour of it.

The one issue we faced was that because it runs things in a separate process, Simplecov was not seeing that certain lines did have test coverage. So a final change was to resolve this based a stackoverflow post we found (https://stackoverflow.com/a/20505441).

So TL;DR

  • the app has a proper CLI
  • the app has tests for its CLI

@Cruikshanks Cruikshanks added the enhancement New feature or request label Sep 8, 2019
@Cruikshanks Cruikshanks self-assigned this Sep 8, 2019
A nice feature to add (plus it gave us some exposure to a couple of new cool tools) was to allow users of the demo app to change the port used by Sinatra. It defaults to 4567, and it's unlikely someone would already be running something on that already.

But just in case we've added the ability to specify a custom port in the app. We've done this by adding [Thor](https://github.com/erikhuda/thor) as a dependency. Thor is a toolkit for building powerful command-line interfaces. In our case it allowed us to

- add a default command
- add a description for that command
- add help on how to use the command
- add support for a custom argument (`--port`)
- add an alias for the custom argument (`-p`)
- add help on how to the custom argument

This meant some refactoring in the project, mainly dropping the `Run` class in favour of a `CLI` class that inherits from Thor.

The second cool tool we added was [Aruba](https://github.com/cucumber/aruba). Aruba allows you to test command-line applications with Cucumber-Ruby, RSpec or Minitest. It essentially runs your app in a separate process but still allows you to make assertions against the behaviour of it.

The one issue we faced was that because it runs things in a separate process, [Simplecov](https://github.com/colszowka/simplecov) was not seeing that certain lines did have test coverage. So a final change was to resolve this based a stackoverflow post we found (https://stackoverflow.com/a/20505441).

So TL;DR

- the app has a proper CLI
- the app has tests for its CLI
@Cruikshanks Cruikshanks merged commit ef27b11 into master Sep 8, 2019
@Cruikshanks Cruikshanks deleted the add-cli-support branch September 8, 2019 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant