Skip to content

Instantly share code, notes, and snippets.

@DavidPiper94
Last active October 20, 2022 05:02
Show Gist options
  • Save DavidPiper94/61dbb18321dd4fdd013f884fb72c7019 to your computer and use it in GitHub Desktop.
Save DavidPiper94/61dbb18321dd4fdd013f884fb72c7019 to your computer and use it in GitHub Desktop.
Example code for article about ArgumentParser - Subcommand
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