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

Show flag aliases before auto-generated names in helptext #247

Merged
merged 3 commits into from
Jan 29, 2025

Conversation

brentyi
Copy link
Owner

@brentyi brentyi commented Jan 28, 2025

Fixes #245

Copy link

codecov bot commented Jan 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.78%. Comparing base (e1deb24) to head (0292f91).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #247   +/-   ##
=======================================
  Coverage   99.78%   99.78%           
=======================================
  Files          28       28           
  Lines        2326     2326           
=======================================
  Hits         2321     2321           
  Misses          5        5           
Flag Coverage Δ
unittests 99.78% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -611,4 +611,4 @@ def _rule_apply_argconf(
if arg.field.argconf.metavar is not None:
lowered.metavar = arg.field.argconf.metavar
if arg.field.argconf.aliases is not None:
lowered.name_or_flags = lowered.name_or_flags + arg.field.argconf.aliases
lowered.name_or_flags = arg.field.argconf.aliases + lowered.name_or_flags
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah. I guess that since all of the aliases are part of the same list, it would require extra work to pull just the short ones out and place them before everything else. In the issue that I filed, I wasn't looking to flip the order of the destination variable-derived name (lowered.name_or_flags) versus all of the aliases... only the short options (e.g., -d.).

However, I'm not against this change. Don't know if it might cause too much surprise to other Tyro users.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yeah, I think all of the options seemed similar:

  1. Pull short args only to the front
  2. Sort by length
  3. Just order as (*user args, automatic arg)

But the final one just seemed the least magical

Copy link
Contributor

Choose a reason for hiding this comment

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

That makes sense: keep it simple. Hopefully none of the other users will complain about the change in order.

@brentyi brentyi merged commit 984c009 into main Jan 29, 2025
17 checks passed
@brentyi brentyi deleted the brent/flip_alias_display_order branch January 29, 2025 12:52
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.

[Minor Feature] Ability to display short options before long options.
2 participants