src/main/java/pityoulish/cmdline/ArgsInterpreter.java
public int handle(String[] args)
    throws Exception
  {
    final int beargc = backendHandler.getArgCount();

    int minargc = beargc;
    if (onlyCommand == null)
       minargc++;

    if (args.length < minargc)
     {
       System.out.println(getUsage());
       return 1;
     }

    final String[] beargs  = Arrays.copyOfRange(args, 0, beargc);
    backendHandler.setBackend(beargs);

    final String   cmdname =
      (onlyCommand != null) ? onlyCommand : args[beargc];
    final String[] cmdargs = Arrays.copyOfRange(args, minargc, args.length);

    StatusCode status = new StatusCode();
    boolean handled = false;
    for(CommandHandler ch : cmdHandlers)
     {
       handled = ch.handle(status, cmdname, cmdargs);
       if (handled)
          return status.code;
     }

    System.out.println(getUsage());
    return 1;

  }
/**
   * Parses command-line arguments and invokes a handler function.
   * If no handler function can be determined, usage information is printed.
   *
   * @param args        the command-line arguments to parse
   *
   * @return    the suggested exit code for the program, 0 for success
   *
   * @throws Exception  in case of a problem
   */
Parses command-line arguments and invokes a handler function.
If no handler function can be determined, usage information is printed.

@param args        the command-line arguments to parse

@return    the suggested exit code for the program, 0 for success

@throws Exception  in case of a problem
Parses command - line arguments and invokes a handler function . If no handler function can be determined usage information is printed . @param args the command - line arguments to parse @return the suggested exit code for the program 0 for success @throws Exception in case of a problem
public int handle(String[] args)
    throws Exception
  {
    final int beargc = backendHandler.getArgCount();
    int minargc = beargc;
    if (onlyCommand == null)
       minargc++;
    if (args.length < minargc)
     {
       System.out.println(getUsage());
       return 1;
     }
    final String[] beargs  = Arrays.copyOfRange(args, 0, beargc);
    backendHandler.setBackend(beargs);
    final String   cmdname =
      (onlyCommand != null) ? onlyCommand : args[beargc];
    final String[] cmdargs = Arrays.copyOfRange(args, minargc, args.length);
    StatusCode status = new StatusCode();
    boolean handled = false;
    for(CommandHandler ch : cmdHandlers)
     {
       handled = ch.handle(status, cmdname, cmdargs);
       if (handled)
          return status.code;
     }
    System.out.println(getUsage());
    return 1;
  }
public int handle ( String [ ] args ) throws Exception { final int beargc = backendHandler . getArgCount ( ) ; int minargc = beargc ; if ( onlyCommand == null ) minargc ++ ; if ( args . length < minargc ) { System . out . println ( getUsage ( ) ) ; return 1 ; } final String [ ] beargs = Arrays . copyOfRange ( args , 0 , beargc ) ; backendHandler . setBackend ( beargs ) ; final String cmdname = ( onlyCommand != null ) ? onlyCommand : args [ beargc ] ; final String [ ] cmdargs = Arrays . copyOfRange ( args , minargc , args . length ) ; StatusCode status = new StatusCode ( ) ; boolean handled = false ; for ( CommandHandler ch : cmdHandlers ) { handled = ch . handle ( status , cmdname , cmdargs ) ; if ( handled ) return status . code ; } System . out . println ( getUsage ( ) ) ; return 1 ; }
Parses command-line arguments and invokes a handler function.
Parses command - line arguments and invokes a handler function .