title: PicoCLI : How to use @ArgGroup for a CommandLine.Command method
body: <p>I have two options (-n and -t) under a command where if -n is used, then -t is required, but bothare not required. However, I keep getting an error about 
  I am trying to send the options as a parameter to another method (with business logic) as a parameter.</p>
  <p>Valid Usage:</p>
  <pre><code>agent.bat install -n -t &lt;blahblah&gt;
  agent.bat install -t &lt;blahblah&gt; -n
  agent.bat install -t &lt;blah blah&gt;
  agent.bat install -t &lt;----This is on interactive so it would ask for a parameter later
  </code></pre>
  <p>Invalid Usage:</p>
  <pre><code>agent.bat install -n
  agent.bat install -n -t
  </code></pre>
  <p>Current output with valid usage:</p>
  <pre><code>agent.bat install -t
  Missing required parameter: '&lt;arg0&gt;'
  Usage: agent install [-hV] &lt;arg0&gt;
  Setup or update the agent service program by install token.
        &lt;arg0&gt;
  </code></pre>
  <pre class="lang-java prettyprint-override"><code>public class Agent implements Callable&lt;Integer&gt; {
      static class InstallArgs {
          @Option(names = {&quot;-t&quot;, &quot;--token&quot;},
                  order = 0,
                  arity = &quot;0..1&quot;,
                  interactive = true,
                  description = &quot;The agent install token.&quot;,
                  required = true) String installToken ;
          @Option(names = {&quot;-n&quot;, &quot;--noninteractive&quot;},
                  order = 1,
                  description = &quot;Sets installation to non-interactive&quot;,
                  required = false) boolean nonInteractive ;
          public String toString() {
              return String.format(&quot;%s,%s&quot;, installToken, nonInteractive);
          }
      }
  
      private static String[] programArgs;
      @ArgGroup(exclusive = false, multiplicity = &quot;1&quot;)
      @CommandLine.Command(name = AgentCommand.INSTALL_COMMAND, mixinStandardHelpOptions = true,
              description = &quot;Setup or update the agent service program by install token.&quot;)
      void install(InstallArgs installArgs) {
          String[] installArgsValues = installArgs.toString().split(&quot;,&quot;);
          String installToken = installArgsValues[0];
          boolean nonInteractive = Boolean.parseBoolean(installArgsValues[1]);
          IcbProgram.initProgramMode(ProgramMode.INSTALL);
          MainService mainService = MainService.createInstallInstance(configFile, agentUserFile, backupAgentUserFile, installToken, nonInteractive);
      }
  
      public static void main(String... args) {
          if (ArgumentValidator.validateArgument(args)) {
              programArgs = args;
              int exitCode = new CommandLine(new Agent()).execute(args);
              System.exit(exitCode);
          } else 
              //Exit with usage error
              System.exit(ExitCode.USAGE);        
      }
  }
  </code></pre>