Merge pull request #4 from kyouko-taiga/issue/2-help Issue/2 help
Merge pull request #4 from kyouko-taiga/issue/2-help
Issue/2 help
Pure Swift utility for command-line options and arguments, inspired by Python’s argpase module.
The following code is a Swift program that takes a list of integers and filters out the even numbers unless asked otherwise.
import ArgParse let parser: ArgumentParser = [ .variadic("elements", defaultValue: [Int]()), .flag("keep-even", alias: "-e"), ] if let parseResult = try? parser.parse(CommandLine.arguments) { let elements: [Int] = parseResult.result(for: "elements")! let keepEven: Bool = parseResult.result(for: "keep-even")! print(elements.filter { $0 % 2 != 0 || keepEven }) }
ArgParse
Pure Swift utility for command-line options and arguments, inspired by Python’s argpase module.
Usage example
The following code is a Swift program that takes a list of integers and filters out the even numbers unless asked otherwise.