# Can ArgumentParser just relax and ignore unknown arguments?

**URL:** <https://forums.swift.org/t/can-argumentparser-just-relax-and-ignore-unknown-arguments/69166>\
**Category:** Using Swift\
**Tags:** packagemanager, command-line-tool\
**Created:** [December 26, 2023, 5:53pm UTC](https://forums.swift.org/t/can-argumentparser-just-relax-and-ignore-unknown-arguments/69166 "2023-12-26T17:53:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jerrykrinock](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jerrykrinock/32/33464_2.png) [@jerrykrinock](https://forums.swift.org/u/jerrykrinock)\
**Post date:** [December 26, 2023, 5:53pm UTC](https://forums.swift.org/t/can-argumentparser-just-relax-and-ignore-unknown-arguments/69166/1 "2023-12-26T17:53:32Z")

</div>

For an odd use case, I'm developing a macOS application (yes, a .app) which uses the Swift package ArgumentParser.

When launching an app, macOS inserts the command-line argument `-NSDocumentRevisionsDebugMode YES`. I do not need the value of this argument, but my `ParsableCommand` must declare it as an `@Option` anyhow. Otherwise, my app prints to the console `Error: Unknown option … Usage: …`, and then quits.

This `-NSDocumentRevisionsDebugMode YES` was not in macOS app launches 20 years ago. If in the future Apple adds some other weird argument to app launching, my app will break.

Is there any way to tell ArgumentParser to just relax and ignore unknown arguments?

---

<div class="post-metadata">

**Author:** ![Pippin](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/pippin/32/24826_2.png) [@Pippin](https://forums.swift.org/u/Pippin)\
**Post date:** [December 26, 2023, 7:10pm UTC](https://forums.swift.org/t/can-argumentparser-just-relax-and-ignore-unknown-arguments/69166/2 "2023-12-26T19:10:29Z")

</div>

You may want to look at the `allUnrecognized` parameter for capturing any unknown arguments.

[https://swiftpackageindex.com/apple/swift-argument-parser/1.3.0/documentation/argumentparser/argumentarrayparsingstrategy/allunrecognized](https://swiftpackageindex.com/apple/swift-argument-parser/1.3.0/documentation/argumentparser/argumentarrayparsingstrategy/allunrecognized)

---

<div class="post-metadata">

**Author:** ![jerrykrinock](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jerrykrinock/32/33464_2.png) [@jerrykrinock](https://forums.swift.org/u/jerrykrinock)\
**Post date:** [December 26, 2023, 8:59pm UTC](https://forums.swift.org/t/can-argumentparser-just-relax-and-ignore-unknown-arguments/69166/3 "2023-12-26T20:59:19Z")

</div>

Thank you, @Pippin. Clearly your answer is the correct, because the documentation there says:

_You can use the `allUnrecognized` parsing strategy to suppress “unexpected argument” errors or …_

When I try this, I get a complier error `Type 'ArgumentArrayParsingStrategy' has no member 'allUnrecognized'`. Maybe I have got an old version of ArgumentParser somehow. This is my first time using a Swift Package, so I shall look elsewhere for how to fix that.

---

<div class="post-metadata">

**Author:** ![jerrykrinock](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jerrykrinock/32/33464_2.png) [@jerrykrinock](https://forums.swift.org/u/jerrykrinock)\
**Post date:** [January 4, 2024, 10:56pm UTC](https://forums.swift.org/t/can-argumentparser-just-relax-and-ignore-unknown-arguments/69166/4 "2024-01-04T22:56:58Z")

</div>

Just to confirm, after I got the current version of ArgumentParser resolved into my project, _allUnrecognized_ does what I need.
