|
// retoor <retoor@molodetz.nl>
|
|
|
|
import "argparse" for ArgumentParser
|
|
|
|
var parser = ArgumentParser.new()
|
|
parser.addArgument("-o", {"long": "--output", "default": "out.txt"})
|
|
parser.addArgument("-n", {"type": "int", "default": 1})
|
|
|
|
var args = parser.parseArgs([])
|
|
System.print(args["output"]) // expect: out.txt
|
|
System.print(args["n"]) // expect: 1
|
|
|
|
var args2 = parser.parseArgs(["-o", "result.txt", "-n", "5"])
|
|
System.print(args2["output"]) // expect: result.txt
|
|
System.print(args2["n"]) // expect: 5
|
|
|
|
var args3 = parser.parseArgs(["--output", "final.txt"])
|
|
System.print(args3["output"]) // expect: final.txt
|