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

Command options should also show up when using --help #26

Merged
merged 6 commits into from
Jun 6, 2018

Conversation

Junkern
Copy link
Contributor

@Junkern Junkern commented Jun 6, 2018

As I kind of need the feature described in oclif/oclif#55 I just went ahead and started.

I have two questions to be able to further continue:

  • How exactly do I write a test for that? I added another options.test.ts inside test/commands. Do I simply need to adapt the expect(ctx.stdout).to.equal(....) to match the desired output?
  • I added code in the args function, but even after a yarn build it does not show the desired output. What am I missing?

Copy link
Contributor

@jdx jdx left a comment

Choose a reason for hiding this comment

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

good change, we should definitely be doing this. A couple things to address but it's mostly ready.

src/command.ts Outdated
let options
if (a.options) {
options = `Can be one of: ${a.options.join(', ')}`
}
let description = a.description || ''
if (a.default) description = `[default: ${a.default}] ${description}`
Copy link
Contributor

Choose a reason for hiding this comment

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

can you instead do:

if (a.options) description = `(${a.options.join('|')}) ${description}`

This will better match how we show flag options.

Also, passing in a 3-length array to the list is likely not going to work in all cases. That behavior I plan to remove as we're not actually using it anyways I don't think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.


// import Help from '..'

export default class OptionsCommand extends Command {
Copy link
Contributor

Choose a reason for hiding this comment

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

this would create a new command for all the CLIs which we definitely do not want. Inline the class like we do here: https://github.com/oclif/plugin-help/blob/master/test/command.test.ts#L116

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense to me now :D I updated the tests

@codecov
Copy link

codecov bot commented Jun 6, 2018

Codecov Report

Merging #26 into master will increase coverage by 0.5%.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master     #26     +/-   ##
========================================
+ Coverage   73.59%   74.1%   +0.5%     
========================================
  Files           7       7             
  Lines         250     251      +1     
  Branches       76      77      +1     
========================================
+ Hits          184     186      +2     
  Misses         27      27             
+ Partials       39      38      -1
Impacted Files Coverage Δ
src/command.ts 83.33% <100%> (+1.79%) ⬆️

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 52150c0...0f59492. Read the comment docs.

@jdx jdx merged commit 0c8d1bf into oclif:master Jun 6, 2018
oclif-bot added a commit that referenced this pull request Jun 6, 2018
<a name="2.0.5"></a>
## [2.0.5](v2.0.4...v2.0.5) (2018-06-06)

### Bug Fixes

* show argument options in help ([#26](#26)) ([0c8d1bf](0c8d1bf))
@oclif-bot
Copy link
Contributor

🎉 This PR is included in version 2.0.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

@salesforce-cla
Copy link

salesforce-cla bot commented Aug 6, 2020

Thanks for the contribution! Unfortunately we can't verify the commit author(s): Martin Wentzel <w***@s***.de>. One possible solution is to add that email to your GitHub account. Alternatively you can change your commits to another email and force push the change. After getting your commits associated with your GitHub account, sign the Salesforce.com Contributor License Agreement and this Pull Request will be revalidated.

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.

None yet

3 participants