Created
June 8, 2011 14:24
-
-
Save Kanasansoft/1014512 to your computer and use it in GitHub Desktop.
[don't use it] wrapper => command line arguments parser library
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 characters
import java.util.List; | |
import com.sampullara.cli.Args; | |
import com.sampullara.cli.Argument; | |
class CommandLineOption { | |
@Argument(value = "help", alias = "h") | |
private Boolean helpFlag = false; | |
List<String> extra = null; | |
@Argument(value = "port", alias = "p", description = "This is the port number") | |
Integer portNo; | |
CommandLineOption(String[] args) { | |
if (args == null) { | |
args = new String[] {}; | |
} | |
try { | |
extra = Args.parse(this, args); | |
} catch (IllegalArgumentException e) { | |
System.err.println(e.getLocalizedMessage()); | |
System.exit(1); | |
} | |
if (helpFlag) { | |
Args.usage(this); | |
System.exit(0); | |
} | |
} | |
} |
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 characters
<dependency> | |
<groupId>com.google.code.cli-parser</groupId> | |
<artifactId>cli</artifactId> | |
<version>7</version> | |
</dependency> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment