![Platform](https://img.shields.io/badge/platform-ios osx linux-999999.svg)
Library for easy and flexible manipulation with CommandLine.arguments
in executable product of Swift Package Manager
Run your executable product via SPM, and pass arguments
$ .build/debug/Project -i input_file -o output_file
Output:
read file input_file
write file output_file
import CommandLineRouter
var router = CommandLineRouter()
// setup routes
router.setCommands(name: "Save file", commands:
Command(shortName: "-i", name: "--input"),
Command(shortName: "-o", name: "--output")
)
router.setCommands(name: "Export in folder", commands:
Command(shortName: "-i", name: "--input"),
Command(shortName: "-of", name: "--output-folder")
)
// process routing
do {
try router.route(CommandLine.arguments) { flow in
switch flow.name {
case "Save file":
let input = flow[0].argument
let output = flow[1].argument
print("read file \(argument)")
print("write file \(argument)")
default: break
}
}
} catch {
print(error)
}