Created
December 30, 2010 14:32
Revisions
-
jpertino created this gist
Dec 30, 2010 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ def cli = new CliBuilder().with { usage = 'program [options] <arguments>' header = 'Options:' footer = '-' * width s 'simplest boolean option' b longOpt: 'both', 'boolean option with both longop and shortop' _ longOpt: 'no-shortop-1', 'boolean option without short version 1' _ longOpt: 'no-shortop-2', 'boolean option without short version 2' n args:1, argName:'thing', 'simple argument option' r args:1, argName:'thing', 'required argument option', required: true u args:2, 'key value argument option, no clue' v args:2, argName:'property=value', valueSeparator:'=', 'key=value argument option' parse(args) ?: System.exit(1) } // -b --no-shortop-1 -r req -u vvv www -v xxx=yyy qwer asdf "1234 5678" zxcv cvbn println 'Arguments: ' << cli.arguments() println '-s: ' << cli.s println '-b: ' << cli.b println '--no-shortop-1: ' << cli.'no-shortop-1' println '--no-shortop-2: ' << cli.'no-shortop-2' println '-n: ' << cli.n println '-r: ' << cli.r println '-u: ' << cli.us println '-v: ' << cli.vs