package org.djutils.cli;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
/**
* Program to test the CLI.
*
* Copyright (c) 2003-2018 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See
* for project information www.simulation.tudelft.nl. The
* source code and binary code of this software is proprietary information of Delft University of Technology.
* @author Alexander Verbraeck
*/
public class Program
{
/** */
@Command(description = "Test program for CLI", name = "Program", mixinStandardHelpOptions = true, version = "1.0")
public static class Options implements Checkable
{
/** */
@Option(names = {"-p", "--port"}, description = "Internet port to use", defaultValue = "80")
private int port;
/** @return the port number */
public int getPort()
{
return this.port;
}
@Override
public void check() throws Exception
{
if (this.port <= 0 || this.port > 65535)
{
throw new Exception("Port should be between 1 and 65535");
}
}
}
/**
* @param args command line args. test with port within range, outside of range, extra argument, --help and -V.
*/
public static void main(final String[] args)
{
Options options = new Options();
CliIUtil.execute(options, args);
System.out.println("port = " + options.getPort());
}
}