Skip to content

Commit 7fa69ff

Browse files
committed
fix(cli): add missing Copilot variant to CliProviderType enum
PR #476 added Copilot as a supported provider but missed adding the Copilot variant to the CliProviderType enum, causing --provider copilot to fail at CLI argument parsing. Also adds a parity test to prevent future drift between CliProviderType and ProviderRegistry. Closes #707
1 parent a1e1d54 commit 7fa69ff

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

crates/openshell-cli/src/main.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,7 @@ enum CliProviderType {
597597
Claude,
598598
Opencode,
599599
Codex,
600+
Copilot,
600601
Generic,
601602
Openai,
602603
Anthropic,
@@ -627,6 +628,7 @@ impl CliProviderType {
627628
Self::Claude => "claude",
628629
Self::Opencode => "opencode",
629630
Self::Codex => "codex",
631+
Self::Copilot => "copilot",
630632
Self::Generic => "generic",
631633
Self::Openai => "openai",
632634
Self::Anthropic => "anthropic",
@@ -3137,4 +3139,29 @@ mod tests {
31373139
other => panic!("expected settings delete command, got: {other:?}"),
31383140
}
31393141
}
3142+
3143+
/// Ensure every provider registered in `ProviderRegistry` has a
3144+
/// corresponding `CliProviderType` variant (and vice-versa).
3145+
/// This test would have caught the missing `Copilot` variant from #707.
3146+
#[test]
3147+
fn cli_provider_types_match_registry() {
3148+
let registry = openshell_providers::ProviderRegistry::new();
3149+
let registry_types: std::collections::BTreeSet<&str> =
3150+
registry.known_types().into_iter().collect();
3151+
3152+
let cli_types: std::collections::BTreeSet<&str> =
3153+
<CliProviderType as ValueEnum>::value_variants()
3154+
.iter()
3155+
.map(CliProviderType::as_str)
3156+
.collect();
3157+
3158+
assert_eq!(
3159+
cli_types,
3160+
registry_types,
3161+
"CliProviderType variants must match ProviderRegistry.known_types(). \
3162+
CLI-only: {:?}, Registry-only: {:?}",
3163+
cli_types.difference(&registry_types).collect::<Vec<_>>(),
3164+
registry_types.difference(&cli_types).collect::<Vec<_>>(),
3165+
);
3166+
}
31403167
}

0 commit comments

Comments
 (0)