mutually-exclusive-group-handler
Generate logic for handling mutually exclusive argument groups with clear error messages and validation in CLI applications.
What this skill does
# Mutually Exclusive Group Handler
Generate logic for handling mutually exclusive CLI argument groups.
## Capabilities
- Generate mutually exclusive group validation
- Create dependent argument relationships
- Set up required group validation
- Implement custom conflict messages
- Configure OR/XOR group logic
- Generate documentation for groups
## Usage
Invoke this skill when you need to:
- Implement mutually exclusive options
- Create dependent argument chains
- Validate argument relationships
- Generate clear conflict messages
## Inputs
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| language | string | Yes | Target language |
| groups | array | Yes | Mutually exclusive group definitions |
### Group Structure
```json
{
"groups": [
{
"name": "output-format",
"type": "mutually_exclusive",
"required": true,
"options": ["--json", "--yaml", "--table"],
"errorMessage": "Choose one output format: --json, --yaml, or --table"
},
{
"name": "auth-method",
"type": "mutually_exclusive",
"options": ["--token", "--username"],
"dependencies": {
"--username": ["--password"]
}
}
]
}
```
## Generated Patterns
### TypeScript Group Handler
```typescript
interface GroupValidation {
name: string;
options: string[];
required?: boolean;
errorMessage?: string;
dependencies?: Record<string, string[]>;
}
export function validateMutuallyExclusiveGroups(
args: Record<string, unknown>,
groups: GroupValidation[]
): void {
for (const group of groups) {
const presentOptions = group.options.filter(opt => {
const key = opt.replace(/^--/, '').replace(/-/g, '_');
return args[key] !== undefined;
});
// Check mutual exclusivity
if (presentOptions.length > 1) {
throw new Error(
group.errorMessage ||
`Options ${presentOptions.join(', ')} are mutually exclusive`
);
}
// Check required group
if (group.required && presentOptions.length === 0) {
throw new Error(
`One of ${group.options.join(', ')} is required`
);
}
// Check dependencies
if (group.dependencies && presentOptions.length === 1) {
const selected = presentOptions[0];
const deps = group.dependencies[selected];
if (deps) {
for (const dep of deps) {
const depKey = dep.replace(/^--/, '').replace(/-/g, '_');
if (args[depKey] === undefined) {
throw new Error(
`${selected} requires ${dep} to be specified`
);
}
}
}
}
}
}
```
### Python Group Handler
```python
from typing import Dict, List, Optional, Any
class MutuallyExclusiveGroup:
def __init__(
self,
name: str,
options: List[str],
required: bool = False,
error_message: Optional[str] = None,
dependencies: Optional[Dict[str, List[str]]] = None
):
self.name = name
self.options = options
self.required = required
self.error_message = error_message
self.dependencies = dependencies or {}
def validate_groups(args: Dict[str, Any], groups: List[MutuallyExclusiveGroup]) -> None:
for group in groups:
present = [
opt for opt in group.options
if args.get(opt.lstrip('-').replace('-', '_')) is not None
]
# Check mutual exclusivity
if len(present) > 1:
raise ValueError(
group.error_message or
f"Options {', '.join(present)} are mutually exclusive"
)
# Check required
if group.required and not present:
raise ValueError(
f"One of {', '.join(group.options)} is required"
)
# Check dependencies
if present and group.dependencies:
selected = present[0]
deps = group.dependencies.get(selected, [])
for dep in deps:
dep_key = dep.lstrip('-').replace('-', '_')
if args.get(dep_key) is None:
raise ValueError(
f"{selected} requires {dep} to be specified"
)
```
## Workflow
1. **Define groups** - Specify mutually exclusive options
2. **Set requirements** - Required vs optional groups
3. **Add dependencies** - Dependent argument chains
4. **Create messages** - Custom error messages
5. **Generate validator** - Validation logic
6. **Generate docs** - Group documentation
## Target Processes
- argument-parser-setup
- error-handling-user-feedback
- cli-command-structure-design
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.