Provide implementations of advanced data structures
The English summary is being prepared. Showing the original description.
Generate logic for handling mutually exclusive argument groups with clear error messages and validation in CLI applications.
The English summary is being prepared. Showing the original description.
See how to installReview the instructions the agent will receive before you install.
Generate logic for handling mutually exclusive CLI argument groups.
Invoke this skill when you need to:
| Parameter | Type | Required | Description |
|---|---|---|---|
| language | string | Yes | Target language |
| groups | array | Yes | Mutually exclusive group definitions |
{
"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"]
}
}
]
}
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`
);
}
}
}
}
}
}
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"
)
No reviews yet. Tell others what you thought.
No login needed. Share how it worked for you, ask a question, or note where it did not run.
No comments yet. Be the first to write one.
Provide implementations of advanced data structures
The English summary is being prepared. Showing the original description.
Fresh adversarial code review with binary PASS/FAIL verdicts, evidence citations, and anchoring bias prevention via fresh reviewer spawning.
The English summary is being prepared. Showing the original description.
WASM-based instant code transforms for simple tasks, achieving 352x speedup over LLM inference with zero cost.
The English summary is being prepared. Showing the original description.
Coordinate Crew (persistent) and Polecat (transient) agents using Gas Town's hook-based work distribution and GUPP principle.
The English summary is being prepared. Showing the original description.
Generate visual representations of algorithm execution
The English summary is being prepared. Showing the original description.
Hierarchical coordination and drift detection with frequent checkpoints, shared memory coherence validation, role specialization enforcement, and short task cycles.
The English summary is being prepared. Showing the original description.