# Can one set up groups of options that "shadow" each other?

**URL:** <https://forums.swift.org/t/can-one-set-up-groups-of-options-that-shadow-each-other/86546>\
**Category:** ArgumentParser\
**Created:** [May 7, 2026, 11:23am UTC](https://forums.swift.org/t/can-one-set-up-groups-of-options-that-shadow-each-other/86546 "2026-05-07T11:23:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![psummerland](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/psummerland/32/45360_2.png) [@psummerland](https://forums.swift.org/u/psummerland)\
**Post date:** [May 7, 2026, 11:23am UTC](https://forums.swift.org/t/can-one-set-up-groups-of-options-that-shadow-each-other/86546/1 "2026-05-07T11:23:04Z")

</div>

Once you get past very simple CLIs, it is common to have conflicting options, especially flags.

Here is how `ls` handles it:

```swift
The -1, -C, -x, and -l options all override each other; the last one specified
determines the format used.

The -c, -u, and -U options all override each other; the last one specified
determines the file time used.

```

Here is `rm`

```swift
The -f option overrides any previous -i options.

The -i option overrides any previous -f options.

```

I haven't figured out how to do this in Argument Parser. Am I missing something?

---

<div class="post-metadata">

**Author:** ![MinerMinerMain](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/minerminermain/32/35300_2.png) [@MinerMinerMain](https://forums.swift.org/u/MinerMinerMain)\
**Post date:** [May 8, 2026, 2:43pm UTC](https://forums.swift.org/t/can-one-set-up-groups-of-options-that-shadow-each-other/86546/2 "2026-05-08T14:43:53Z")

</div>

You might want to look into [Custom Enumerable Flags](https://swiftpackageindex.com/apple/swift-argument-parser/1.7.1/documentation/argumentparser/flag#Custom-Enumerable-Flags). It lets you support non-binary Flags.

This should reimplement the `rm` command’s `-f`,`-i` and `-I` flags with Swift Argument Parser

```swift
enum PromptMode {
    case never
    case always
    case once
    case unassigned
}

extension PromptMode: EnumerableFlag {
    static func name(for value: Self) -> NameSpecification {
        switch value {
        case .never: return [.customShort("f"),.customLong("force")]
        case .once: return .customShort("I")
        case .always: return .customShort("i")
        default: return [] // No Flags for internal modes
        }
    }
    
    static func help(for value: Self) -> ArgumentHelp? {
        switch value {
        case .never: return "ignore nonexistent files, never prompt"
        case .once: return "prompt once before removing more than three files or when removing recursively"
        case .always: return "prompt before every removal"
        default: return .init("This is an internal mode and has no flags", visibility: .private)
        }
    }
}

```

You can put it in your `ParsableCommand` with

```swift
@Flag(exclusivity: .chooseLast)
var promptMode: PromptMode = .unassigned

```

---

<div class="post-metadata">

**Author:** ![psummerland](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/psummerland/32/45360_2.png) [@psummerland](https://forums.swift.org/u/psummerland)\
**Post date:** [May 8, 2026, 3:46pm UTC](https://forums.swift.org/t/can-one-set-up-groups-of-options-that-shadow-each-other/86546/3 "2026-05-08T15:46:56Z")

</div>

Thanks. Especially for writing out the example.
