@ Override public String getUsage ( ) { String commandName = name ; Class < ? > declaringClass = method . getDeclaringClass ( ) ; Map < String , Cmd > commands = Commands . get ( declaringClass ) ; if ( commands . size ( ) == 1 && commands . values ( ) . iterator ( ) . next ( ) instanceof CmdGroup ) { final CmdGroup cmdGroup = ( CmdGroup ) commands . values ( ) . iterator ( ) . next ( ) ; commandName = cmdGroup . getName ( ) + " " + name ; } final String usage = usage ( ) ; if ( usage != null ) { if ( ! usage . startsWith ( commandName ) ) { return commandName + " " + usage ; } else { return usage ; } } final List < Object > args = new ArrayList <> ( ) ; for ( final Param parameter : spec . arguments ) { boolean skip = Environment . class . isAssignableFrom ( parameter . getType ( ) ) ; for ( final Annotation a : parameter . getAnnotations ( ) ) { final CrestAnnotation crestAnnotation = a . annotationType ( ) . getAnnotation ( CrestAnnotation . class ) ; if ( crestAnnotation != null ) { skip = crestAnnotation . skipUsage ( ) ; break ; } } if ( ! skip ) { skip = parameter . getAnnotation ( NotAService . class ) == null && Environment . ENVIRONMENT_THREAD_LOCAL . get ( ) . findService ( parameter . getType ( ) ) != null ; } if ( skip ) { continue ; } args . add ( parameter . getDisplayType ( ) . replace ( "[]" , "..." ) ) ; } return String . format ( "%s %s %s" , commandName , args . size ( ) == method . getParameterTypes ( ) . length ? "" : "[options]" , Join . join ( " " , args ) ) . trim ( ) ; }
Returns a single line description of the command