Skip to content

Add support for dual long options when no short option#2312

Merged
shadowspawn merged 7 commits intotj:developfrom
shadowspawn:feature/dual-long-option-flags
Jan 13, 2025
Merged

Add support for dual long options when no short option#2312
shadowspawn merged 7 commits intotj:developfrom
shadowspawn:feature/dual-long-option-flags

Conversation

@shadowspawn
Copy link
Copy Markdown
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
@shadowspawn shadowspawn deleted the feature/dual-long-option-flags branch January 13, 2025 04:30
@shadowspawn shadowspawn added the pending release Merged into a branch for a future release, but not released yet label Jan 14, 2025
@shadowspawn shadowspawn removed the pending release Merged into a branch for a future release, but not released yet label Jan 21, 2025
jelmore1674 pushed a commit to jelmore1674/build-changelog that referenced this pull request Mar 19, 2025
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [commander](https://github.com/tj/commander.js) | devDependencies | minor | [`13.0.0` -> `13.1.0`](https://renovatebot.com/diffs/npm/commander/13.0.0/13.1.0) |

---

### Release Notes

<details>
<summary>tj/commander.js (commander)</summary>

### [`v13.1.0`](https://github.com/tj/commander.js/blob/HEAD/CHANGELOG.md#1310-2025-01-21)

[Compare Source](tj/commander.js@v13.0.0...v13.1.0)

##### Added

-   support a pair of long option flags to allow a memorable shortened flag, like `.option('--ws, --workspace')` (\[[#&#8203;2312](tj/commander.js#2312)])

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xMTguMiIsInVwZGF0ZWRJblZlciI6IjM5LjEzMy40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Reviewed-on: https://gitea.justinelmore.dev/jelmore1674/build-changelog/pulls/80
Co-authored-by: Renovate Bot <renovate-bot@forgejo.justinelmore.dev>
Co-committed-by: Renovate Bot <renovate-bot@forgejo.justinelmore.dev>
raineorshine added a commit to raineorshine/npm-check-updates that referenced this pull request Sep 29, 2025
raineorshine added a commit to raineorshine/npm-check-updates that referenced this pull request Sep 29, 2025
raineorshine added a commit to raineorshine/npm-check-updates that referenced this pull request Sep 29, 2025
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