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

help output: Order default runtime options #11

Closed
hedgehog opened this issue Dec 20, 2009 · 7 comments
Closed

help output: Order default runtime options #11

hedgehog opened this issue Dec 20, 2009 · 7 comments

Comments

@hedgehog
Copy link

Sometimes the output is:

Runtime options:
  -p, [--pretend]  # Run but do not make any changes
  -q, [--quiet]    # Supress status output
  -s, [--skip]     # Skip files that already exist
  -f, [--force]    # Overwrite files that already exist

Other times:

Runtime options:
  -s, [--skip]     # Skip files that already exist
  -p, [--pretend]  # Run but do not make any changes
  -q, [--quiet]    # Supress status output
  -f, [--force]    # Overwrite files that already exist
@hedgehog
Copy link
Author

hedgehog commented Jan 1, 2010

ideally would be sorted, a-z, by the long-form option name;

@josevalim
Copy link
Contributor

At first we had an ordered hash implementation to keep the order of the options as they are added, but it was adding a lot of implementation issues. So we just use a Hash, because they will be ordered in 1.9 (and possibly in 1.8.8).

@hedgehog
Copy link
Author

hedgehog commented Jan 1, 2010

this is a biggie when you are writting a cli script - I really need to know what my user help text looks like. No idea what the oerdered hash issues were - ignorance is bliss :)
I'm not sure an ordered hash would scratch the itch... with many options users will appreciate/want a sorted list, so maybe allow the script author to pass a help option: sorted => true ?

@josevalim
Copy link
Contributor

It should be a class configuration option, something along this line:

class App < Thor
sort_options_alphabetically!
end

If you provide a patch, I will merge it. But, sorry, I won't merge your whole stack because having test code in lib/thor.rb looks like a smell to me.

@hedgehog
Copy link
Author

hedgehog commented Jan 1, 2010

I had in mind :ordered_help => true/false in the options hash of:
desc()
method_option()

Not sure what other methods it could be passed to....
Default is true and Capitalized option names are given priority.
Behavior would be the ordered_help would appear above the unordered help, and would respect groupings.
But as you've noticed I'm new to Thor so this might not be feasible given the time.

@josevalim
Copy link
Contributor

The default should be the order you declare. You can always declare alphabetically. Github does not allow to reopen issues, so please do when you have a patch.

@hedgehog
Copy link
Author

hedgehog commented Jan 1, 2010

Good point, the name is ambiguous. sorted_help is the accurate option name.

This issue was closed.
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

No branches or pull requests

2 participants