# ParsableCommand Design with Codependent Options

**URL:** <https://forums.swift.org/t/parsablecommand-design-with-codependent-options/73157>\
**Category:** ArgumentParser\
**Created:** [July 13, 2024, 7:59pm UTC](https://forums.swift.org/t/parsablecommand-design-with-codependent-options/73157 "2024-07-13T19:59:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cseal](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/cseal/32/37735_2.png) [@cseal](https://forums.swift.org/u/cseal)\
**Post date:** [July 13, 2024, 7:59pm UTC](https://forums.swift.org/t/parsablecommand-design-with-codependent-options/73157/1 "2024-07-13T19:59:39Z")

</div>

**Context**  
I am developing a tool using ArgumentParser to fetch data from a public API. The API and Swift tool works like so:

- `command` Returns entire API dataset from [api.example.com](http://api.example.com)
- `command --option1 val1` Returns a narrower dataset from [api.example.com/val1](http://api.example.com/val1)
- `command --option1 val1 --option2 val2` Returns an even narrower set of data from [api.example.com/val1/val2](http://api.example.com/val1/val2)
- `command --option1 val1 --option2 val2 --option3 val3` Returns a single data item from [api.example.com/val1/val2/val3](http://api.example.com/val1/val2/val3)

So, option2 requires option1, and option3 requires option2. Here is a generalized example of my code:

```swift
struct MyOptions: ParsableArguments {
    @Option option1: Type? = nil
    @Option option2: Type? = nil
    @Option option3: Type? = nil
}

struct MyCommand: ParsableCommand {
    @OptionGroup var options: MyOptions
    mutating func run() throws {}
}

```

**Questions**  
For handling checking for allowed option combinations, I was planning to have some logic in the `run()` function to check when constructing the API's URL path. But it seems like this logic should be moved to a custom `validate()`? Also, more of a general swift question, but is there a way to utilize the default validate() implementation in my own? That way I just handle the mutual dependencies and don’t need to implement the basic argument checking. It seems `super` is only allowed in Swift classes.
