Skip to content

Commit d96f110

Browse files
committed
refactor(cli): drop -d/-m short aliases; loosen version pins
Two unrelated changes in one commit: 1. Drop the `-d` short for `--dry-run` and `-m` short for `--manifest-path` from `GlobalArgs`. We want those letters free for future flags. The long forms are unaffected, and a new `reserved_short_forms_are_not_assigned` compose test locks in that no subcommand reassigns either letter. Per-subcommand short-form tests (`*_short`, `manifest_path_short_form`, etc.) are deleted; the long-form counterparts cover the contract. 2. Loosen `python-version` and `ruby-version` pins in ci.yml from exact patch (`3.12.13`, `3.2.10`) to minor.x (`3.12.x`, `3.2.x`). setup-python and setup-ruby's catalogs keep retiring older patch versions and breaking the workflow — minor.x auto-resolves to whatever patch is currently available. CLI_CONTRACT.md updated to remove `-d`/`-m` from the global args table and the env-var cross-reference. Assisted-by: Claude Code:opus-4-7
1 parent 833e80e commit d96f110

11 files changed

Lines changed: 53 additions & 74 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ jobs:
376376
- name: Setup Python
377377
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
378378
with:
379-
python-version: '3.12.13'
379+
python-version: '3.12.x'
380380

381381
- name: Run pypi dispatch tests
382382
run: python pypi/socket-patch/test_dispatch.py
@@ -445,15 +445,16 @@ jobs:
445445
if: matrix.suite == 'e2e_pypi'
446446
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
447447
with:
448-
python-version: '3.12.13'
448+
python-version: '3.12.x'
449449

450450
- name: Setup Ruby
451451
if: matrix.suite == 'e2e_gem'
452452
uses: ruby/setup-ruby@319994f95fa847cf3fb3cd3dbe89f6dcde9f178f # v1.295.0
453453
with:
454-
# 3.2.11 was removed from setup-ruby's catalog; 3.2.10 is the
455-
# newest 3.2.x available on the GitHub-hosted runner.
456-
ruby-version: '3.2.10'
454+
# Pin to minor.x so setup-ruby auto-resolves to the latest
455+
# available 3.2.x patch — exact patch pins kept dropping out
456+
# of the catalog as new releases landed.
457+
ruby-version: '3.2.x'
457458
bundler-cache: false
458459

459460
- name: Run e2e tests

crates/socket-patch-cli/CLI_CONTRACT.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ In v3.0 every subcommand accepts the same set of "global" flags via a single sha
2626
| Long | Short | Env var | Default | Type | Semantic |
2727
|---|---|---|---|---|---|
2828
| `--cwd` || `SOCKET_CWD` | `.` | path | Working directory |
29-
| `--manifest-path` | `-m` | `SOCKET_MANIFEST_PATH` | `.socket/manifest.json` | path | Manifest location (resolved relative to `--cwd`) |
29+
| `--manifest-path` | | `SOCKET_MANIFEST_PATH` | `.socket/manifest.json` | path | Manifest location (resolved relative to `--cwd`) |
3030
| `--api-url` || `SOCKET_API_URL` | `https://api.socket.dev` | string | Authenticated API endpoint |
3131
| `--api-token` || `SOCKET_API_TOKEN` | (none) | string | Auth token (absence selects the public proxy) |
3232
| `--org` | `-o` | `SOCKET_ORG_SLUG` | (auto-resolve) | string | Org slug |
@@ -39,7 +39,7 @@ In v3.0 every subcommand accepts the same set of "global" flags via a single sha
3939
| `--json` | `-j` | `SOCKET_JSON` | `false` | bool | Machine-readable output |
4040
| `--verbose` | `-v` | `SOCKET_VERBOSE` | `false` | bool | Extra detail |
4141
| `--silent` | `-s` | `SOCKET_SILENT` | `false` | bool | Errors only |
42-
| `--dry-run` | `-d` | `SOCKET_DRY_RUN` | `false` | bool | Preview, no mutations |
42+
| `--dry-run` | | `SOCKET_DRY_RUN` | `false` | bool | Preview, no mutations |
4343
| `--yes` | `-y` | `SOCKET_YES` | `false` | bool | Skip prompts |
4444
| `--debug` || `SOCKET_DEBUG` | `false` | bool | Verbose debug logs to stderr |
4545
| `--no-telemetry` || `SOCKET_TELEMETRY_DISABLED` | `false` | bool | Disable anonymous usage telemetry |
@@ -80,7 +80,7 @@ All v3.0 env vars use the `SOCKET_*` prefix. Three legacy `SOCKET_PATCH_*` names
8080
| Env var | CLI equivalent | Default | Notes |
8181
|---|---|---|---|
8282
| `SOCKET_CWD` | `--cwd` | `.` ||
83-
| `SOCKET_MANIFEST_PATH` | `--manifest-path` / `-m` | `.socket/manifest.json` ||
83+
| `SOCKET_MANIFEST_PATH` | `--manifest-path` | `.socket/manifest.json` ||
8484
| `SOCKET_API_URL` | `--api-url` | `https://api.socket.dev` ||
8585
| `SOCKET_API_TOKEN` | `--api-token` | (none) | Absence selects the public proxy. |
8686
| `SOCKET_ORG_SLUG` | `--org` / `-o` | (auto-resolve) ||
@@ -93,7 +93,7 @@ All v3.0 env vars use the `SOCKET_*` prefix. Three legacy `SOCKET_PATCH_*` names
9393
| `SOCKET_JSON` | `--json` / `-j` | `false` ||
9494
| `SOCKET_VERBOSE` | `--verbose` / `-v` | `false` ||
9595
| `SOCKET_SILENT` | `--silent` / `-s` | `false` ||
96-
| `SOCKET_DRY_RUN` | `--dry-run` / `-d` | `false` ||
96+
| `SOCKET_DRY_RUN` | `--dry-run` | `false` ||
9797
| `SOCKET_YES` | `--yes` / `-y` | `false` ||
9898
| `SOCKET_DEBUG` | `--debug` | `false` | **Renamed in v3.0** (was `SOCKET_PATCH_DEBUG`). |
9999
| `SOCKET_TELEMETRY_DISABLED` | `--no-telemetry` | `false` | **Renamed in v3.0** (was `SOCKET_PATCH_TELEMETRY_DISABLED`). |

crates/socket-patch-cli/src/args.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ pub struct GlobalArgs {
3636
/// Path to patch manifest file (resolved relative to --cwd).
3737
#[arg(
3838
long = "manifest-path",
39-
short = 'm',
4039
env = "SOCKET_MANIFEST_PATH",
4140
default_value = DEFAULT_PATCH_MANIFEST_PATH,
4241
)]
@@ -133,7 +132,6 @@ pub struct GlobalArgs {
133132
/// Preview the operation without making any mutations.
134133
#[arg(
135134
long = "dry-run",
136-
short = 'd',
137135
env = "SOCKET_DRY_RUN",
138136
default_value_t = false,
139137
)]

crates/socket-patch-cli/tests/cli_global_args.rs

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,21 @@ fn every_global_flag_parses_on_every_subcommand() {
8989
}
9090
}
9191

92-
/// Short forms (`-d`, `-s`, `-y`, etc.) are part of the contract too.
92+
/// Short forms (`-s`, `-y`, etc.) are part of the contract too. `-d`
93+
/// and `-m` were dropped after v3.0 (they were reserved as aliases for
94+
/// `--dry-run` and `--manifest-path` but we want those letters free
95+
/// for future flags); the corresponding rejection check lives in
96+
/// `reserved_short_forms_are_not_assigned` below.
9397
#[test]
9498
fn every_global_short_form_parses_on_every_subcommand() {
9599
// (short, requires_value) — only flags that actually have a short.
96100
let shorts: &[(&str, bool)] = &[
97-
("-m", true), // --manifest-path
98101
("-o", true), // --org
99102
("-e", true), // --ecosystems
100103
("-g", false), // --global
101104
("-j", false), // --json
102105
("-v", false), // --verbose
103106
("-s", false), // --silent
104-
("-d", false), // --dry-run
105107
("-y", false), // --yes
106108
];
107109
let all_subcommands: Vec<&str> = SUBCOMMANDS_NO_POSITIONAL
@@ -132,6 +134,42 @@ fn every_global_short_form_parses_on_every_subcommand() {
132134
}
133135
}
134136

137+
/// `-d` and `-m` were intentionally dropped (formerly aliases for
138+
/// `--dry-run` and `--manifest-path`) so those letters stay free for
139+
/// future flags. Lock that in: clap must reject the bare shorts on
140+
/// every subcommand. The long forms still work and are exercised by
141+
/// `every_global_flag_parses_on_every_subcommand` above.
142+
#[test]
143+
fn reserved_short_forms_are_not_assigned() {
144+
let all_subcommands: Vec<&str> = SUBCOMMANDS_NO_POSITIONAL
145+
.iter()
146+
.chain(SUBCOMMANDS_WITH_IDENTIFIER.iter())
147+
.copied()
148+
.collect();
149+
for &subcommand in &all_subcommands {
150+
for short in ["-d", "-m"] {
151+
let result = try_parse(subcommand, &[short]);
152+
assert!(
153+
result.is_err(),
154+
"`{}` should NOT accept the reserved short `{}` — \
155+
if you bound it intentionally, update this test and \
156+
the corresponding `--help` docs.",
157+
subcommand,
158+
short,
159+
);
160+
let err = result.err().unwrap();
161+
assert_eq!(
162+
err.kind(),
163+
clap::error::ErrorKind::UnknownArgument,
164+
"expected UnknownArgument when `{}` is passed to `{}`; got {:?}",
165+
short,
166+
subcommand,
167+
err.kind(),
168+
);
169+
}
170+
}
171+
}
172+
135173
/// Locks the env-var bindings: setting a SOCKET_* env var must populate
136174
/// the corresponding GlobalArgs field on parse.
137175
///

crates/socket-patch-cli/tests/cli_parse_apply.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@ fn dry_run_long() {
7070
assert!(parse_apply(&["--dry-run"]).common.dry_run);
7171
}
7272

73-
#[test]
74-
fn dry_run_short() {
75-
assert!(parse_apply(&["-d"]).common.dry_run);
76-
}
77-
7873
#[test]
7974
fn silent_long() {
8075
assert!(parse_apply(&["--silent"]).common.silent);
@@ -142,11 +137,6 @@ fn manifest_path_long() {
142137
);
143138
}
144139

145-
#[test]
146-
fn manifest_path_short() {
147-
assert_eq!(parse_apply(&["-m", "custom.json"]).common.manifest_path, "custom.json");
148-
}
149-
150140
#[test]
151141
fn global_prefix_long() {
152142
assert_eq!(

crates/socket-patch-cli/tests/cli_parse_list.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@ fn defaults_match_contract() {
4747
assert!(!args.common.json);
4848
}
4949

50-
#[test]
51-
fn manifest_path_short_form() {
52-
let args = parse_list(&["-m", "custom.json"]);
53-
assert_eq!(args.common.manifest_path, "custom.json");
54-
}
55-
5650
#[test]
5751
fn manifest_path_long_form() {
5852
let args = parse_list(&["--manifest-path", "custom.json"]);

crates/socket-patch-cli/tests/cli_parse_remove.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,6 @@ fn global_long_form() {
8383
assert!(args.common.global);
8484
}
8585

86-
#[test]
87-
fn manifest_path_short_form() {
88-
let args = parse_remove(&["pkg:npm/foo@1", "-m", "custom/manifest.json"]);
89-
assert_eq!(args.common.manifest_path, "custom/manifest.json");
90-
}
91-
9286
#[test]
9387
fn manifest_path_long_form() {
9488
let args = parse_remove(&[
@@ -133,7 +127,7 @@ fn all_flags_combined() {
133127
"pkg:npm/foo@1",
134128
"--cwd",
135129
"/tmp/x",
136-
"-m",
130+
"--manifest-path",
137131
"custom/manifest.json",
138132
"--skip-rollback",
139133
"-y",

crates/socket-patch-cli/tests/cli_parse_repair.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,12 @@ fn repair_defaults_match_contract() {
5353
assert!(!args.common.json);
5454
}
5555

56-
#[test]
57-
fn repair_dry_run_short_flag() {
58-
let args = parse_repair(&["-d"]);
59-
assert!(args.common.dry_run);
60-
}
61-
6256
#[test]
6357
fn repair_dry_run_long_flag() {
6458
let args = parse_repair(&["--dry-run"]);
6559
assert!(args.common.dry_run);
6660
}
6761

68-
#[test]
69-
fn repair_manifest_path_short_flag() {
70-
let args = parse_repair(&["-m", "custom.json"]);
71-
assert_eq!(args.common.manifest_path, "custom.json");
72-
}
73-
7462
#[test]
7563
fn repair_manifest_path_long_flag() {
7664
let args = parse_repair(&["--manifest-path", "custom.json"]);

crates/socket-patch-cli/tests/cli_parse_rollback.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,6 @@ fn positional_identifier_purl() {
5757
assert_eq!(args.identifier, Some("pkg:npm/foo@1".to_string()));
5858
}
5959

60-
#[test]
61-
fn dry_run_short() {
62-
let args = parse_rollback(&["-d"]);
63-
assert!(args.common.dry_run);
64-
}
65-
6660
#[test]
6761
fn dry_run_long() {
6862
let args = parse_rollback(&["--dry-run"]);
@@ -81,12 +75,6 @@ fn silent_long() {
8175
assert!(args.common.silent);
8276
}
8377

84-
#[test]
85-
fn manifest_path_short() {
86-
let args = parse_rollback(&["-m", "custom.json"]);
87-
assert_eq!(args.common.manifest_path, "custom.json");
88-
}
89-
9078
#[test]
9179
fn manifest_path_long() {
9280
let args = parse_rollback(&["--manifest-path", "custom.json"]);

crates/socket-patch-cli/tests/cli_parse_scan.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,6 @@ fn dry_run_long_form() {
274274
assert!(args.common.dry_run);
275275
}
276276

277-
#[test]
278-
fn dry_run_short_form() {
279-
let args = parse_scan(&["-d"]);
280-
assert!(args.common.dry_run);
281-
}
282-
283277
#[test]
284278
fn scan_json_empty_cwd_emits_updates_key() {
285279
// Spawn the compiled binary against an empty tempdir so no API call

0 commit comments

Comments
 (0)