# ArgumentParser

**URL:** https://forums.swift.org/c/related-projects/argumentparser/60.md?page=1

[Latest](https://forums.swift.org/latest.md) · [Categories](https://forums.swift.org/categories.md) · [Tags](https://forums.swift.org/tags.md)

**Page:** 2

---

## [Interactivity support in the argument parser](https://forums.swift.org/t/interactivity-support-in-the-argument-parser/75222)

<div class="topic-metadata">

**Author:** [@natanrolnik](https://forums.swift.org/u/natanrolnik)\
**Replies:** 1\
**Last updated:** [October 8, 2024, 12:39pm UTC](https://forums.swift.org/t/interactivity-support-in-the-argument-parser/75222 "2024-10-08T12:39:48Z")

</div>

Hello there! While preparing a blog post about interactivity in CLI tools, I ended up writing a property wrapper that encapsulated a logic around readLine(). Then I thought - how can I make it compatible with the argume…

---

## [Is it possible to create commands at runtime?](https://forums.swift.org/t/is-it-possible-to-create-commands-at-runtime/74836)

<div class="topic-metadata">

**Author:** [@marciniwanicki](https://forums.swift.org/u/marciniwanicki)\
**Replies:** 0\
**Last updated:** [September 21, 2024, 7:58pm UTC](https://forums.swift.org/t/is-it-possible-to-create-commands-at-runtime/74836 "2024-09-21T19:58:38Z")

</div>

I'd love to add a very basic plugin system to my CLI project. If a certain file (plugin) is detected, I want to expose it via the command parser as a new command. Is it possible to add new commands (ParsableCommand) at …

---

## [ArgumentParser/Option.swift:82: Fatal error: Can't read a value from a parsable argument definition](https://forums.swift.org/t/argumentparser-option-swift-fatal-error-cant-read-a-value-from-a-parsable-argument-definition/62359)

<div class="topic-metadata">

**Author:** [@morpheus](https://forums.swift.org/u/morpheus)\
**Replies:** 1\
**Last updated:** [September 21, 2024, 5:17pm UTC](https://forums.swift.org/t/argumentparser-option-swift-fatal-error-cant-read-a-value-from-a-parsable-argument-definition/62359 "2024-09-21T17:17:36Z")

</div>

I am new to Swift. I am using this library like this: @main final class Program: Options, ParsableCommand { ... } where class Options { @Option(name: \[.customShort("w"), .long\], help: "Image width (inches)") var …

---

## [Dump-help question](https://forums.swift.org/t/dump-help-question/74762)

<div class="topic-metadata">

**Author:** [@Joseph\_Heck](https://forums.swift.org/u/Joseph_Heck)\
**Replies:** 2\
**Last updated:** [September 20, 2024, 1:13am UTC](https://forums.swift.org/t/dump-help-question/74762 "2024-09-20T01:13:56Z")

</div>

I was recently digging the output generated by the --experimental-dump-help option, looking at the potential to use it to generate integrated DocC documentation for CLI executables (related thread in DocC about CLI docum…

---

## [Compile a Single Swift File Against the Argument Parser Package (Without Using SwiftPM for the Executable)](https://forums.swift.org/t/compile-a-single-swift-file-against-the-argument-parser-package-without-using-swiftpm-for-the-executable/73012)

<div class="topic-metadata">

**Author:** [@tree\_frog](https://forums.swift.org/u/tree_frog)\
**Replies:** 6\
**Last updated:** [July 23, 2024, 7:15am UTC](https://forums.swift.org/t/compile-a-single-swift-file-against-the-argument-parser-package-without-using-swiftpm-for-the-executable/73012 "2024-07-23T07:15:57Z")

</div>

Hello, I'm having a terrible time figuring out how to compile a single .swift file using swiftc against a downloaded & locally-built copy of ArgumentParser, without using SPM for the executable. For background on why …

---

## [ParsableCommand Design with Codependent Options](https://forums.swift.org/t/parsablecommand-design-with-codependent-options/73157)

<div class="topic-metadata">

**Author:** [@cseal](https://forums.swift.org/u/cseal)\
**Replies:** 0\
**Last updated:** [July 13, 2024, 7:59pm UTC](https://forums.swift.org/t/parsablecommand-design-with-codependent-options/73157 "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 command --option1 val1 Returns a narro…

---

## [Grouping subcommands](https://forums.swift.org/t/grouping-subcommands/72219)

<div class="topic-metadata">

**Author:** [@Douglas\_Gregor](https://forums.swift.org/u/Douglas_Gregor)\
**Replies:** 7\
**Last updated:** [June 4, 2024, 9:13pm UTC](https://forums.swift.org/t/grouping-subcommands/72219 "2024-06-04T21:13:58Z")

</div>

Hey all, In a discussion on adding another swift package subcommand, we came across the idea of "grouping" common subcommands under a common heading. This can improve the readability of the generated "help" when there a…

---

## [Mutually exclusive parameters?](https://forums.swift.org/t/mutually-exclusive-parameters/71633)

<div class="topic-metadata">

**Author:** [@jzi](https://forums.swift.org/u/jzi)\
**Replies:** 3\
**Last updated:** [May 9, 2024, 5:43pm UTC](https://forums.swift.org/t/mutually-exclusive-parameters/71633 "2024-05-09T17:43:22Z")

</div>

Is there a way to express that a command line tool which declares two parameters expects either one or the other to be passed by the caller? Or does this need to be handled in a validate() method?

---

## [Type inference difference using CMake/Xcode?](https://forums.swift.org/t/type-inference-difference-using-cmake-xcode/71086)

<div class="topic-metadata">

**Author:** [@dabrahams](https://forums.swift.org/u/dabrahams)\
**Replies:** 4\
**Last updated:** [April 25, 2024, 11:43pm UTC](https://forums.swift.org/t/type-inference-difference-using-cmake-xcode/71086 "2024-04-25T23:43:45Z")

</div>

I was wondering if anyone else is already aware of this bug which affects any project using CMake to build ArgumentParser. If anyone knows a workaround, I'd love to hear about it.

---

## [Handling options common to all subcommands in ArgumentParser?](https://forums.swift.org/t/handling-options-common-to-all-subcommands-in-argumentparser/71329)

<div class="topic-metadata">

**Author:** [@JetForMe](https://forums.swift.org/u/JetForMe)\
**Replies:** 2\
**Last updated:** [April 17, 2024, 10:18pm UTC](https://forums.swift.org/t/handling-options-common-to-all-subcommands-in-argumentparser/71329 "2024-04-17T22:18:09Z")

</div>

I'm working on a little tool to talk to my 3D printer. It has a handful of subcommands, but they all need an address and password supplied as options. I'd like to factor those options into the root command. If I declare …

---

## [AsyncParsableCommand doesn't work?](https://forums.swift.org/t/asyncparsablecommand-doesnt-work/71300)

<div class="topic-metadata">

**Author:** [@JetForMe](https://forums.swift.org/u/JetForMe)\
**Replies:** 2\
**Last updated:** [April 17, 2024, 5:32pm UTC](https://forums.swift.org/t/asyncparsablecommand-doesnt-work/71300 "2024-04-17T17:32:34Z")

</div>

I’m trying to build a command line tool that uses async/await. ArgumentParser supports this, by simply inheriting from AsyncParsableCommand and making the run method async. Unfortunately, when I do that, it fails to par…

---

## [How do I save values only while the terminal is open?](https://forums.swift.org/t/how-do-i-save-values-only-while-the-terminal-is-open/71150)

<div class="topic-metadata">

**Author:** [@Keisuke\_C](https://forums.swift.org/u/Keisuke_C)\
**Replies:** 9\
**Last updated:** [April 11, 2024, 8:18am UTC](https://forums.swift.org/t/how-do-i-save-values-only-while-the-terminal-is-open/71150 "2024-04-11T08:18:36Z")

</div>

We are currently creating a client tool for a social networking service. However, each subcommand requires the user ID and password to be entered, making the command lengthy. Is there any way to carry over the command l…

---

## [Release soon with Sendable CommandConfiguration?](https://forums.swift.org/t/release-soon-with-sendable-commandconfiguration/70477)

<div class="topic-metadata">

**Author:** [@James\_Dempsey](https://forums.swift.org/u/James_Dempsey)\
**Replies:** 2\
**Last updated:** [March 6, 2024, 8:33pm UTC](https://forums.swift.org/t/release-soon-with-sendable-commandconfiguration/70477 "2024-03-06T20:33:21Z")

</div>

I see that CommandConfiguration adds the Sendable protocol on the main branch. This addresses the warning in Swift 5.10 with strict concurrency turned on: Static property 'configuration' is not concurrency-safe becaus…

---

## [Argument parser contribution](https://forums.swift.org/t/argument-parser-contribution/69135)

<div class="topic-metadata">

**Author:** [@chattu](https://forums.swift.org/u/chattu)\
**Replies:** 0\
**Last updated:** [December 22, 2023, 5:01pm UTC](https://forums.swift.org/t/argument-parser-contribution/69135 "2023-12-22T17:01:57Z")

</div>

what should i know to contribute to argument parser.

---

## [What’s the right way to create a command line tool using ArgumentParser? \`swift package\` or Xcode create Mac command line tool project?](https://forums.swift.org/t/what-s-the-right-way-to-create-a-command-line-tool-using-argumentparser-swift-package-or-xcode-create-mac-command-line-tool-project/68050)

<div class="topic-metadata">

**Author:** [@young](https://forums.swift.org/u/young)\
**Replies:** 6\
**Last updated:** [October 25, 2023, 11:13pm UTC](https://forums.swift.org/t/what-s-the-right-way-to-create-a-command-line-tool-using-argumentparser-swift-package-or-xcode-create-mac-command-line-tool-project/68050 "2023-10-25T23:13:11Z")

</div>

I believe the right way to create an ArgumentParser command line tool is: swift package init --type tool --name MyTool Then open Package.swift in Xcode. But then I cannot add this package: The “My Mac" target disapp…

---

## [How to setup my arguments: two flag -ios -macos : can only set one to true](https://forums.swift.org/t/how-to-setup-my-arguments-two-flag-ios-macos-can-only-set-one-to-true/67897)

<div class="topic-metadata">

**Author:** [@young](https://forums.swift.org/u/young)\
**Replies:** 2\
**Last updated:** [October 16, 2023, 10:27pm UTC](https://forums.swift.org/t/how-to-setup-my-arguments-two-flag-ios-macos-can-only-set-one-to-true/67897 "2023-10-16T22:27:31Z")

</div>

I want my command to work like this: mytool --ios # do iOS mytool --macos. # do macOS mytool # must choose either --ios or --macos I think this can be done with: enum OSType: ExpressibleByA…

---

## [How to exclude members from parsing](https://forums.swift.org/t/how-to-exclude-members-from-parsing/34325)

<div class="topic-metadata">

**Author:** [@Lantua](https://forums.swift.org/u/Lantua)\
**Replies:** 16\
**Last updated:** [October 3, 2023, 5:47pm UTC](https://forums.swift.org/t/how-to-exclude-members-from-parsing/34325 "2023-10-03T17:47:18Z")

</div>

So ParsableArguments requires that all members use one of their property wrappers. I'm trying to add defaulted properties that won't participate in the parsing. In so far, I've used a wrapper that ignores decoding @pr…

---

## [Xcode runs swift script with gradle process but in terminal it hangs with no output](https://forums.swift.org/t/xcode-runs-swift-script-with-gradle-process-but-in-terminal-it-hangs-with-no-output/67556)

<div class="topic-metadata">

**Author:** [@doozMen](https://forums.swift.org/u/doozMen)\
**Replies:** 3\
**Last updated:** [September 28, 2023, 1:25pm UTC](https://forums.swift.org/t/xcode-runs-swift-script-with-gradle-process-but-in-terminal-it-hangs-with-no-output/67556 "2023-09-28T13:25:28Z")

</div>

I have this fascinating problem that when I ran a process in a swift commandline tool in xcode it triggers gradle, or gradlew (both have the problem), and it shows output. The same thing ran from commandline does not out…

---

## [Issue with ArgumentParser - Code stopped working without changes](https://forums.swift.org/t/issue-with-argumentparser-code-stopped-working-without-changes/65452)

<div class="topic-metadata">

**Author:** [@erik\_avagyan](https://forums.swift.org/u/erik_avagyan)\
**Replies:** 3\
**Last updated:** [June 13, 2023, 5:14am UTC](https://forums.swift.org/t/issue-with-argumentparser-code-stopped-working-without-changes/65452 "2023-06-13T05:14:25Z")

</div>

Hello everyone, I'm new to Swift and I'm currently facing a strange issue with ArgumentParser. Recently, my code using ArgumentParser has stopped working without any changes being made to the codebase. I'm hoping to get…

---

## [Executable name transformed in usage output?](https://forums.swift.org/t/executable-name-transformed-in-usage-output/65095)

<div class="topic-metadata">

**Author:** [@dabrahams](https://forums.swift.org/u/dabrahams)\
**Replies:** 1\
**Last updated:** [May 20, 2023, 12:24am UTC](https://forums.swift.org/t/executable-name-transformed-in-usage-output/65095 "2023-05-20T00:24:34Z")

</div>

I have a build tool plugin in my project that uses ArgumentParser. When I look at its invocation, I'm seeing this: ' /Users/dave/src/val/.build/arm64-apple-macosx/debug/GenerateValFileTests -o /Users/dave/src/val/.bui…

---

## ['no such file' errors with ArgumentParser package](https://forums.swift.org/t/no-such-file-errors-with-argumentparser-package/62183)

<div class="topic-metadata">

**Author:** [@benwiggy](https://forums.swift.org/u/benwiggy)\
**Replies:** 24\
**Last updated:** [January 3, 2023, 2:14pm UTC](https://forums.swift.org/t/no-such-file-errors-with-argumentparser-package/62183 "2023-01-03T14:14:49Z")

</div>

I'm trying to create a command line tool, so obviously want to use ArgumentParser. I've added the Package to my project, (as far as I can tell), and initially, when I build, I get these errors: dyld\[20971\]: Library not …

---

## [Vending GenerateManualPlugin](https://forums.swift.org/t/vending-generatemanualplugin/61296)

<div class="topic-metadata">

**Author:** [@mackoj](https://forums.swift.org/u/mackoj)\
**Replies:** 0\
**Last updated:** [November 8, 2022, 8:50am UTC](https://forums.swift.org/t/vending-generatemanualplugin/61296 "2022-11-08T08:50:15Z")

</div>

Hi, I have built an SPM Plugin that uses a CLI that uses swift-argument-parser but how can I hide or not vend GenerateManualPlugin ? Thanks,

---

## [How to share code between multiple subcommands](https://forums.swift.org/t/how-to-share-code-between-multiple-subcommands/61132)

<div class="topic-metadata">

**Author:** [@Xarbrough](https://forums.swift.org/u/Xarbrough)\
**Replies:** 4\
**Last updated:** [October 31, 2022, 11:18am UTC](https://forums.swift.org/t/how-to-share-code-between-multiple-subcommands/61132 "2022-10-31T11:18:41Z")

</div>

How can I reuse code within subcommands in order to make my command line app more maintainable? This question is mostly about which language features and paradigms to apply when working with the Argument Parser. Here's …

---

## [Pass negative number as command line argument](https://forums.swift.org/t/pass-negative-number-as-command-line-argument/60129)

<div class="topic-metadata">

**Author:** [@Todd21](https://forums.swift.org/u/Todd21)\
**Replies:** 9\
**Last updated:** [September 6, 2022, 8:54pm UTC](https://forums.swift.org/t/pass-negative-number-as-command-line-argument/60129 "2022-09-06T20:54:05Z")

</div>

Is there a way to pass a negative number as an option or command line argument to ArgumentParser? For example, the code below generates an error when I try to pass a -5 as the optional value. % ./parsetest2 num…

---

## [Which argument is the completion closure called for](https://forums.swift.org/t/which-argument-is-the-completion-closure-called-for/59523)

<div class="topic-metadata">

**Author:** [@CraigSiemens](https://forums.swift.org/u/CraigSiemens)\
**Replies:** 0\
**Last updated:** [August 8, 2022, 5:02pm UTC](https://forums.swift.org/t/which-argument-is-the-completion-closure-called-for/59523 "2022-08-08T17:02:40Z")

</div>

When creating a custom completion, a closure is called that is passed all the currently typed in arguments. Is there a way to tell which arguement the user is editing that causes the closure to be called? My command is …

---

## [When to use SwiftPM plugin for generating \`man\` pages?](https://forums.swift.org/t/when-to-use-swiftpm-plugin-for-generating-man-pages/59010)

<div class="topic-metadata">

**Author:** [@MarcoEidinger](https://forums.swift.org/u/MarcoEidinger)\
**Replies:** 4\
**Last updated:** [July 18, 2022, 7:08pm UTC](https://forums.swift.org/t/when-to-use-swiftpm-plugin-for-generating-man-pages/59010 "2022-07-18T19:08:11Z")

</div>

I am intrigued by the latest addition in ArgumentParser 1.1.3 by @rauhul ArgumentParser now includes a SwiftPM plugin for generating man pages. Explore the functionality and configuration by running swift package plug…

---

## [Subcommand auto-routing with argv0](https://forums.swift.org/t/subcommand-auto-routing-with-argv0/57809)

<div class="topic-metadata">

**Author:** [@jamesez](https://forums.swift.org/u/jamesez)\
**Replies:** 10\
**Last updated:** [June 5, 2022, 3:21am UTC](https://forums.swift.org/t/subcommand-auto-routing-with-argv0/57809 "2022-06-05T03:21:21Z")

</div>

We're in the process of unifying a bunch of small tools into a single binary and using a subcommand to launch the specific tool. I have a potentially unknown number of scripts calling some of these tools, so it'd be han…

---

## [Is it possible to build a command with an asynchronous subcommand on macOS 11?](https://forums.swift.org/t/is-it-possible-to-build-a-command-with-an-asynchronous-subcommand-on-macos-11/57418)

<div class="topic-metadata">

**Author:** [@dirtyhenry](https://forums.swift.org/u/dirtyhenry)\
**Replies:** 0\
**Last updated:** [May 18, 2022, 11:17am UTC](https://forums.swift.org/t/is-it-possible-to-build-a-command-with-an-asynchronous-subcommand-on-macos-11/57418 "2022-05-18T11:17:23Z")

</div>

Am I correct if I say it is currently impossible to build a root async command that has subcommands with macOS 11? My root command needs to be asynchronous because one of the subcommands is asynchronous. When I tried to…

---

## [Parse Error](https://forums.swift.org/t/parse-error/57231)

<div class="topic-metadata">

**Author:** [@davidnorris78](https://forums.swift.org/u/davidnorris78)\
**Replies:** 1\
**Last updated:** [May 18, 2022, 2:05am UTC](https://forums.swift.org/t/parse-error/57231 "2022-05-18T02:05:09Z")

</div>

I'm trying to read in a ParsableCommand into a App to then post a Notification on macOS, but I'm running into an error when the app is trying to parse the CommandLine arguments. Using Xcode 13.3.1. App deployment targe…

---

## [Bypass missing option or value validation?](https://forums.swift.org/t/bypass-missing-option-or-value-validation/56658)

<div class="topic-metadata">

**Author:** [@DefSecSentinel](https://forums.swift.org/u/DefSecSentinel)\
**Replies:** 9\
**Last updated:** [April 11, 2022, 6:03pm UTC](https://forums.swift.org/t/bypass-missing-option-or-value-validation/56658 "2022-04-11T18:03:10Z")

</div>

Hey, I'm new too Swift and to using Argument Parser but I'm really enjoying it so far. I've implemented a list @Flag that when used (or set to true) will list data contained in specific arrays depending on what command-l…

[Previous page](https://forums.swift.org/c/related-projects/argumentparser/60.md)

[Next page](https://forums.swift.org/c/related-projects/argumentparser/60.md?page=2)
