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

Fixes #28440 - Help contains squeezed options #323

Merged
merged 1 commit into from
Apr 23, 2020

Conversation

ofedoren
Copy link
Member

@ofedoren ofedoren commented Jan 27, 2020

This PR introduces a way to squeeze options in help output by grouping the options in 'families'.

TODO:

  • - Docs
  • - Tests

Example (for better examples see theforeman/hammer-cli-foreman#489):

class MyCommand
  option_family(description: 'Desc for the main switch') do
    parent '--item-id', '', 'Item desc 1'
    child '--item', '', 'Item desc 2'
  end
end

# > hammer -h
# ...
# Options:
#   --item[-id]            Desc for the main switch
# ...
# > hammer full-help
# ...
# Options:
#   --item                   Item desc 2
#   --item-id                Item desc 1
# ... 

@xprazak2
Copy link
Contributor

xprazak2 commented Feb 4, 2020

Provides a base for squeezed options and seems ok, but my knowledge in this area is fairly limited.

@ofedoren ofedoren force-pushed the feat-28440-squeeze-options branch 2 times, most recently from ede13f7 to 597c47b Compare February 11, 2020 15:38
@ofedoren ofedoren force-pushed the feat-28440-squeeze-options branch 2 times, most recently from d761c6b to 6ee19a9 Compare April 21, 2020 15:09
@ofedoren ofedoren changed the title [WIP]Fixes #28440 - Help contains squeezed options Fixes #28440 - Help contains squeezed options Apr 21, 2020
Copy link
Contributor

@shiramax shiramax left a comment

Choose a reason for hiding this comment

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

great work @ofedoren !

option_family(options = {}) do
# parent is the main option. Must be single, option family can have only one parent.
parent switches, type, description, options
# child is an additional option. Could be none or more than one. Aren't shown in the help output.
Copy link
Contributor

Choose a reason for hiding this comment

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

switch is not so clear to me in that context. what does it means?

Copy link
Member Author

Choose a reason for hiding this comment

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

switches are '--something' or ['--option-one', '--option-two']. It's how it's named in Clamp.

@shiramax shiramax merged commit 869eba9 into theforeman:master Apr 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants