Package org.jboss.aesh.cl

Examples of org.jboss.aesh.cl.CommandLine


            if (output != null && output.getBuffer().trim().length() > 0) {
                try (CommandContainer commandContainer = getCommand(
                    Parser.findFirstWord(output.getBuffer()),
                    output.getBuffer())) {

                    CommandLine commandLine = commandContainer.getParser()
                        .parse(output.getBuffer());

                    commandContainer
                        .getParser()
                        .getCommandPopulator()
                        .populateObject(commandContainer.getCommand(),
                            commandLine, invocationProviders, getAeshContext(), true);
                    // validate the command before execute, only call if no
                    // options with overrideRequired is not set
                    if (commandContainer.getParser().getCommand()
                        .getValidator() != null
                        && !commandLine.hasOptionWithOverrideRequired())
                        commandContainer.getParser().getCommand()
                            .getValidator()
                            .validate(commandContainer.getCommand());
                    result = commandContainer
                        .getCommand()
View Full Code Here


    /**
     * Only called when we know that the last word is an option value
     * If endsWithSpace is true we set the value to an empty string to indicate a value
     */
    private ParsedCompleteObject findCompleteObjectValue(String line, boolean endsWithSpace) throws CommandLineParserException {
        CommandLine cl = parser.parse(line, true);

        //the last word is an argument
        if(cl.getArgument() != null && !cl.getArgument().getValues().isEmpty()) {
            return new ParsedCompleteObject("", endsWithSpace ? "" :
                    cl.getArgument().getValues().get(cl.getArgument().getValues().size() - 1),
                    cl.getArgument().getType(), false);
        }
        //get the last option
        else if (cl.getOptions() != null && cl.getOptions().size() > 0) {
            ProcessedOption po = cl.getOptions().get(cl.getOptions().size()-1);
            //options ends with a separator and thus status should be set accordingly
            if(po.getEndsWithSeparator())
                endsWithSpace = true;

            if(endsWithSpace && po.getValue() != null &&  po.getValue().length() > 0 &&
                    (po.getOptionType() == OptionType.NORMAL || po.getOptionType() == OptionType.BOOLEAN)) {
                if(cl.getArgument() == null)
                    return new ParsedCompleteObject(true, "", 0);
                else
                    return new ParsedCompleteObject(true);
            }
            else if(po.isLongNameUsed() || (po.getShortName() == null || po.getShortName().length() < 1))
View Full Code Here

   {
      WizardCommandController controller = getController();
      Map<String, InputComponent<?, ?>> pageInputs = new LinkedHashMap<>(controller.getInputs());
      allInputs.putAll(pageInputs);
      CommandLineParser parser = commandLineUtil.generateParser(controller, shellContext, allInputs);
      CommandLine cmdLine = parser.parse(line, true);
      Map<String, InputComponent<?, ?>> populatedInputs = commandLineUtil.populateUIInputs(cmdLine, allInputs);

      // Second pass to ensure disabled fields are set
      parser = commandLineUtil.generateParser(controller, shellContext, allInputs);
      cmdLine = parser.parse(line, true);
View Full Code Here

      {
         // get latest command added
         ShellCommand currentCommand = wizardSteps.get(wizardSteps.size() - 1);
         try
         {
            CommandLine cl = currentCommand.parse(output.getBuffer());
            if (cl != null)
            {
               // populate the inputs to the context
               CommandLineUtil.populateUIInputs(cl, currentCommand.getContext(), registry);
               currentCommand.getContext().setConsoleOutput(output);
View Full Code Here

      }

      private int parseUICommand(ConsoleOutput output) throws IOException
      {
         int result = 1;
         CommandLine cl = null;
         for (ShellCommand command : commands)
         {
            try
            {
               cl = command.parse(output.getBuffer());
View Full Code Here

            if (output != null && output.getBuffer().trim().length() > 0) {
                try (CommandContainer commandContainer = getCommand(
                        Parser.findFirstWord(output.getBuffer()),
                        output.getBuffer())) {

                    CommandLine commandLine = commandContainer.getParser()
                            .parse(output.getBuffer());

                    commandContainer
                            .getParser()
                            .getCommandPopulator()
                            .populateObject(commandContainer.getCommand(),
                                    commandLine, invocationProviders, true);
                    // validate the command before execute, only call if no
                    // options with overrideRequired is not set
                    if (commandContainer.getParser().getCommand()
                            .getValidator() != null
                            && !commandLine.hasOptionWithOverrideRequired())
                        commandContainer.getParser().getCommand()
                                .getValidator()
                                .validate(commandContainer.getCommand());
                    result = commandContainer
                            .getCommand()
View Full Code Here

    /**
     * Only called when we know that the last word is an option value
     * If endsWithSpace is true we set the value to an empty string to indicate a value
     */
    private ParsedCompleteObject findCompleteObjectValue(String line, boolean endsWithSpace) throws CommandLineParserException {
        CommandLine cl = parser.parse(line, true);

        //the last word is an argument
        if(cl.getArgument() != null && !cl.getArgument().getValues().isEmpty()) {
            return new ParsedCompleteObject("", endsWithSpace ? "" :
                    cl.getArgument().getValues().get(cl.getArgument().getValues().size() - 1),
                    cl.getArgument().getType(), false);
        }
        //get the last option
        else if (cl.getOptions() != null && cl.getOptions().size() > 0) {
            ProcessedOption po = cl.getOptions().get(cl.getOptions().size()-1);
            //options ends with a separator and thus status should be set accordingly
            if(po.getEndsWithSeparator())
                endsWithSpace = true;

            if(endsWithSpace && po.getValue() != null &&  po.getValue().length() > 0 &&
View Full Code Here

            if (output != null && output.getBuffer().trim().length() > 0) {
                try (CommandContainer commandContainer = getCommand(
                    Parser.findFirstWord(output.getBuffer()),
                    output.getBuffer())) {

                    CommandLine commandLine = commandContainer.getParser()
                        .parse(output.getBuffer());

                    commandContainer
                        .getParser()
                        .getCommandPopulator()
                        .populateObject(commandContainer.getCommand(),
                            commandLine, invocationProviders, true);
                    // validate the command before execute, only call if no
                    // options with overrideRequired is not set
                    if (commandContainer.getParser().getCommand()
                        .getValidator() != null
                        && !commandLine.hasOptionWithOverrideRequired())
                        commandContainer.getParser().getCommand()
                            .getValidator()
                            .validate(commandContainer.getCommand());
                    result = commandContainer
                        .getCommand()
View Full Code Here

    /**
     * Only called when we know that the last word is an option value
     * If endsWithSpace is true we set the value to an empty string to indicate a value
     */
    private ParsedCompleteObject findCompleteObjectValue(String line, boolean endsWithSpace) throws CommandLineParserException {
        CommandLine cl = parser.parse(line, true);

        //the last word is an argument
        if(cl.getArgument() != null && !cl.getArgument().getValues().isEmpty()) {
            return new ParsedCompleteObject("", endsWithSpace ? "" :
                    cl.getArgument().getValues().get(cl.getArgument().getValues().size() - 1),
                    cl.getArgument().getType(), false);
        }
        //get the last option
        else if (cl.getOptions() != null && cl.getOptions().size() > 0) {
            ProcessedOption po = cl.getOptions().get(cl.getOptions().size()-1);
            //options ends with a separator and thus status should be set accordingly
            if(po.getEndsWithSeparator())
                endsWithSpace = true;

            if(endsWithSpace && po.getValue() != null &&  po.getValue().length() > 0 &&
                    (po.getOptionType() == OptionType.NORMAL || po.getOptionType() == OptionType.BOOLEAN)) {
                if(cl.getArgument() == null)
                    return new ParsedCompleteObject(true, "", 0);
                else
                    return new ParsedCompleteObject(true);
            }
            else if(po.isLongNameUsed() || (po.getShortName() == null || po.getShortName().length() < 1))
View Full Code Here

        if(aeshLine.getWords().size() > 0) {
            if(command.getName().equals(aeshLine.getWords().get(0)))
                return parse(aeshLine.getWords(), ignoreRequirements);
        }
        else if(aeshLine.getStatus() != ParserStatus.OK)
            return new CommandLine(new CommandLineParserException(aeshLine.getErrorMessage()));

        return new CommandLine(new CommandLineParserException("Command:"+ command +", not found in: "+line));
    }
View Full Code Here

TOP

Related Classes of org.jboss.aesh.cl.CommandLine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.