Last active
October 20, 2022 05:02
-
-
Save DavidPiper94/61dbb18321dd4fdd013f884fb72c7019 to your computer and use it in GitHub Desktop.
Example code for article about ArgumentParser - Subcommand
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct CLINotes: ParsableCommand { | |
// 1 | |
static let configuration: CommandConfiguration = CommandConfiguration( | |
commandName: "clinotes", | |
abstract: "Manage your notes from the command line", | |
discussion: "Create your nodes from the command-line. Each file generated with this tool has the extension \(fileExtension).", | |
subcommands: [Write.self] | |
) | |
static let fileExtension = ".clinote" | |
// 2 | |
struct Write: ParsableCommand { | |
static let configuration: CommandConfiguration = CommandConfiguration( | |
commandName: "write", | |
abstract: "Writes given text to file at given file path." | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment