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 support for dual long options when no short option #2312

Merged
merged 7 commits into from
Jan 13, 2025

Conversation

shadowspawn
Copy link
Collaborator

@shadowspawn shadowspawn commented Jan 11, 2025

Problem

#2270 throws an exception for unsupported option setups. This is picking up more variations than expected, and use of a short-ish form is more widespread than assumed (despite being at odds with the documented usage).

In particular, people want to have a multi-character shortish option.

Solution

The high level goals are still to restrict usage to supported formats, and follow standard conventions.

As per #2307 (comment)

Short version: my latest thinking is to add explicit support for a short-ish option, but with double-dash rather than single dash.

Long version

There are strong conventions for short options (POSIX) and long options (GNU). I am uncomfortable about supporting a third and non-standard variation with multi-character short option.

But I appreciate the author desire for a more memorable short-ish option than a single character.

Adding explicit support for a double-dash short-ish option feels like a more pure approach still offering the key benefit. e.g. --es, --ecmascript <year>

There are no new behaviours that need to be decided or described for the short-ish option, and it is full featured. Can you embed option value with a short-ish option? Of course, --es=2018. Can you combined short and short-ish options in a single argument after a single dash? Of course not.

So:

  • Multiple character short option: no, conflicts with standard posix and incomplete (no embedded value support). Use double dash instead. See next item.
  • dual long options: yes, add support for this as the intended format for "shortish" option like --ws, --workspace
  • triple dash: no, rare

ChangeLog

  • add: support for a pair of long option flags to allow a short-ish flag, like .option('--ws, --workspace')

@shadowspawn

This comment was marked as outdated.

@shadowspawn shadowspawn marked this pull request as ready for review January 12, 2025 02:56
@shadowspawn shadowspawn merged commit 8263b7f into tj:develop Jan 13, 2025
11 checks passed
@shadowspawn shadowspawn deleted the feature/dual-long-option-flags branch January 13, 2025 04:30
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.

2 participants