Class Simple

  • All Implemented Interfaces:
    ExampleRunnable

    @Command(name="simple",
             description="A simple example command")
    public class Simple
    extends java.lang.Object
    implements ExampleRunnable
    A simple example that demonstrates most of the basic concepts

    We use the Command annotation to indicate that a class is going to represent a command and then the Option annotation to indicate fields whose values should be populated by options

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.List<java.lang.String> args
      The Arguments annotation allows commands to take in additional arbitrary arguments
      private boolean flag  
      private HelpOption<Simple> help
      The special HelpOption provides a -h and --help option that can be used to request that help be shown.
      private java.lang.String name
      Here we declare an option that requires a value by using the arity field of the Option annotation
      private int number
      As we declare this field to be of type int Airline will ensure that the value passed to this option can be converted to an integer and throws an error if this is not possible
    • Constructor Summary

      Constructors 
      Constructor Description
      Simple()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void main​(java.lang.String[] args)  
      int run()
      Runs the command and returns an exit code that the application should return
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • flag

        @Option(name={"-f","--flag"},
                description="An option that requires no arguments")
        private boolean flag
      • name

        @Option(name={"-n","--name"},
                title="Name",
                arity=1,
                description="An option that takes an argument")
        private java.lang.String name
        Here we declare an option that requires a value by using the arity field of the Option annotation
      • number

        @Option(name="--number",
                title="Number",
                arity=1,
                description="An option that takes a numeric argument")
        private int number
        As we declare this field to be of type int Airline will ensure that the value passed to this option can be converted to an integer and throws an error if this is not possible
      • args

        @Arguments
        private java.util.List<java.lang.String> args
        The Arguments annotation allows commands to take in additional arbitrary arguments
    • Constructor Detail

      • Simple

        public Simple()
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
      • run

        public int run()
        Description copied from interface: ExampleRunnable
        Runs the command and returns an exit code that the application should return
        Specified by:
        run in interface ExampleRunnable
        Returns:
        Exit code