Provide assistance for the command line.

@return {@code true} if assistance could be provided for the command line.
347692
public boolean assist() {
        // Read the command line and provide assistance for the command line before the caret.
        final String commandLine = commandLineManager.getCommandLine();
        final int caret = commandLineManager.getCaret();
        final String commandLineToAssist = commandLine.substring(0, caret);
        final Opt<String> autoCompletedSuffix = shell.assist(commandLineToAssist);
        if (!autoCompletedSuffix.isPresent()) {
            return false;
        }

        // Don't overwrite any extra characters on the command line that came after the caret.
        final String extraCommandLine = commandLine.substring(caret);
        final String autoCompletedCommandLine = commandLineToAssist + autoCompletedSuffix.get();
        commandLineManager.setCommandLine(autoCompletedCommandLine + extraCommandLine);
        commandLineManager.setCaret(autoCompletedCommandLine.length());
        return true;
    }
371681
@Override
	public void run(Line line) {
		List<String> args = line.args();
		
		if (args.isEmpty()) {
			shell.console().println(usage().toString());
			return;
		}
		
		String command = line.args().get(0);
		Command c = shell.commands().get(command);
		
		if (c == null) {
			shell.console().println("no help topic for '" + command + "'");
			return;
		}
		
		shell.console().println(c.usage().toString());
	}
989366
public static void main(String[] args) {
    org.apache.commons.cli.Options cliOptions = createCliOptions();
    try {
      CommandLine cli = parseCli(args, cliOptions);
      Options options = loadOptions(cli);
      validate(options);
      ConstraintParser parser = new ConstraintParser(options);
      try {
        output(parser, options.getOutputFile());
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    } catch (IncompleteCliException e) {
      // If the command line is not complete just print usage and help
      printErrorWithUsageAndHelp(cliOptions);
    }
  }
793200
def help(ctx, command):
    """"""
    command = ' '.join(command)
    if not command:
        click.echo(cli.get_help(ctx))
        return

    cmd = cli.get_command(ctx, command)
    if cmd:
        click.echo(cmd.get_help(ctx))
    else:
        click.echo(cli.get_help(ctx))
872833
public int run(String... args) {

    CliParser parser = getParserBuilder().build(this);
    try {
      CliModeObject mode = parser.parseParameters(args);
      if (this.help) {
        assert (mode.getId().equals(CliMode.ID_HELP));
        printHelp(parser);
        return 0;
      }
      validate(mode);
      return run(mode);
    } catch (Exception e) {
      return handleError(e, parser);
    } finally {
      getStandardOutput().flush();
      getStandardError().flush();
    }
  }
1089946
public void help() {

        m_shell.getOut().println();
        m_shell.getOut().println(getMessages().key(Messages.GUI_SHELL_HELP1_0));
        m_shell.getOut().println(getMessages().key(Messages.GUI_SHELL_HELP2_0));
        m_shell.getOut().println(getMessages().key(Messages.GUI_SHELL_HELP3_0));
        m_shell.getOut().println(getMessages().key(Messages.GUI_SHELL_HELP4_0));
        m_shell.getOut().println();
    }
385495
public CommandLine parseArgs(final String[] args) throws CLIToolOptionsException {
        initOptions();
        final CommandLineParser parser = new PosixParser();
        try {
            commandLine = parser.parse(getOptions(), args);
        } catch (ParseException e) {
            help();
            throw new CLIToolOptionsException(e);
        }
        if (null != toolOptions) {
            for (final CLIToolOptions toolOpts : toolOptions) {
                toolOpts.parseArgs(commandLine, args);
            }
        }
        return commandLine;
    }
283624
public boolean canPing() {
        try {
            val connection = (HttpURLConnection) new URL(this.swivelUrl).openConnection();
            connection.setRequestMethod(HttpMethod.GET.name());
            connection.connect();
            return connection.getResponseCode() == HttpStatus.SC_OK;
        } catch (final Exception e) {
            LOGGER.warn(e.getMessage(), e);
        }
        return false;
    }
1292960
@SuppressFBWarnings("DM_EXIT")
    public static void showHelp(TextUICommandLine commandLine) {
        showSynopsis();
        ShowHelp.showGeneralOptions();
        FindBugs.showCommandLineOptions(commandLine);
        System.exit(1);
    }
393748
@Pure
	public static List<Object> getCommandLineOption(String name) {
		if (commandLineOptions != null && commandLineOptions.containsKey(name)) {
			final List<Object> value = commandLineOptions.get(name);
			return value == null ? Collections.emptyList() : value;
		}
		return Collections.emptyList();
	}
305661
public function helpStubCommand()
    {
        $context = $this->bootstrap->getContext();
        $applicationPackage = $this->packageManager->getPackage($this->applicationPackageKey);
        $this->outputLine('<b>%s %s ("%s" context)</b>', [$this->applicationName, $applicationPackage->getInstalledVersion() ?: 'dev', $context]);
        $this->outputLine('<i>usage: %s <command identifier></i>', [$this->getFlowInvocationString()]);
        $this->outputLine();
        $this->outputLine('See "%s help" for a list of all available commands.', [$this->getFlowInvocationString()]);
        $this->outputLine();
    }
457287
private boolean checkNumArguments() {
        //Also, since we're iterating over all options and args, use this opportunity to recreate the commandLineString
        final StringBuilder commandLineString = new StringBuilder();
        try {
            for (final OptionDefinition optionDefinition : optionDefinitions) {
                final String fullName = prefixDot + optionDefinition.name;
                final StringBuilder mutextOptionNames = new StringBuilder();
                for (final String mutexOption : optionDefinition.mutuallyExclusive) {
                    final OptionDefinition mutextOptionDef = optionMap.get(mutexOption);
                    if (mutextOptionDef != null && mutextOptionDef.hasBeenSet) {
                        mutextOptionNames.append(' ').append(prefixDot).append(mutextOptionDef.name);
                    }
                }
                if (optionDefinition.hasBeenSet && mutextOptionNames.length() > 0) {
                    messageStream.println("ERROR: Option '" + fullName +
                            "' cannot be used in conjunction with option(s)" +
                            mutextOptionNames.toString());
                    return false;
                }
                if (optionDefinition.isCollection) {
                    final Collection<?> c = (Collection<?>) optionDefinition.field.get(optionDefinition.parent);
                    if (c.size() < optionDefinition.minElements) {
                        messageStream.println("ERROR: Option '" + fullName + "' must be specified at least " +
                                optionDefinition.minElements + " times.");
                        return false;
                    }
                } else if (!optionDefinition.optional && !optionDefinition.hasBeenSet &&
                        !optionDefinition.hasBeenSetFromParent && mutextOptionNames.length() == 0) {
                    messageStream.print("ERROR: Option '" + fullName + "' is required");
                    if (optionDefinition.mutuallyExclusive.isEmpty()) {
                        messageStream.println(".");
                    } else {
                        messageStream.println(" unless any of " + optionDefinition.mutuallyExclusive +
                                " are specified.");
                    }
                    return false;
                }
            }

            if (positionalArguments != null) {
                final Collection<?> c = (Collection<?>) positionalArguments.get(callerOptions);
                if (c.size() < minPositionalArguments) {
                    messageStream.println("ERROR: At least " + minPositionalArguments +
                            " positional arguments must be specified.");
                    return false;
                }
                for (final Object posArg : c) {
                    commandLineString.append(' ').append(posArg.toString());
                }
            }
            //first, append args that were explicitly set
            for (final OptionDefinition optionDefinition : optionDefinitions) {
                if (optionDefinition.hasBeenSet) {
                    commandLineString.append(' ').append(prefixDot).append(optionDefinition.name).append('=').append(
                            optionDefinition.field.get(optionDefinition.parent));
                }
            }
            commandLineString.append("   "); //separator to tell the 2 apart
            //next, append args that weren't explicitly set, but have a default value
            for (final OptionDefinition optionDefinition : optionDefinitions) {
                if (!optionDefinition.hasBeenSet && !optionDefinition.defaultValue.equals("null")) {
                    commandLineString.append(' ').append(prefixDot).append(optionDefinition.name).append('=').append(
                            optionDefinition.defaultValue);
                }
            }
            this.commandLine += commandLineString.toString();
            return true;
        } catch (final IllegalAccessException e) {
            // Should never happen because lack of publicness has already been checked.
            throw new RuntimeException(e);
        }
    }
238747
@Override
    public void handle(CommandContext ctx) throws CommandLineException {

        recognizeArguments(ctx);

        if(helpArg.isPresent(ctx.getParsedCommandLine())) {
            printHelp(ctx);
            return;
        }

        if(!isAvailable(ctx)) {
            throw new CommandFormatException("The command is not available in the current context (e.g. required subsystems or connection to the controller might be unavailable).");
        }

        doHandle(ctx);
    }
282709
public String getHelp() {
		StringBuilder sb = new StringBuilder(data.size() * HELP_TEXT_LENGTH_PER_PARAM);

		sb.append("Required Parameters:");
		sb.append(HELP_TEXT_LINE_DELIMITER);

		for (Option o : data.values()) {
			sb.append(this.helpText(o));
		}
		sb.append(HELP_TEXT_LINE_DELIMITER);

		return sb.toString();
	}
635771
private boolean doStart()
  {
    if (! _lifecycle.isActive()) {
      return false;
    }
    
    if (! isEnable()) {
      return false;
    }
    
    int startingCount = _startingCount.get();

    int threadCount = _threadCount.get() + startingCount;

    if (_threadMax < threadCount) {
      onThreadMax();
      
      return false;
    }
    else if (! isIdleTooLow(startingCount)) {
      return false;
    }
    
    _idleCount.incrementAndGet();

    startConnection();
      
    return true;
  }
1238087
public T getHelper() {
        if (this.helper == null) {
            if (this.destroyed) {
                throw new IllegalStateException("A call to shutdown has already been made and the helper cannot be used after that point");
            }
            this.helper = this.createHelper();
            logger.trace("{}: got new helper {} from OpenHelperManager", this, this.helper);
        }
        return this.helper;
    }
371599
public static void main(String[] args) throws Exception {
    ArgP argp = new ArgP();
    argp.addOption("--help", "Print help information.");
    CliOptions.addCommon(argp);
    FsckOptions.addDataOptions(argp);
    args = CliOptions.parse(argp, args);

    if (argp.has("--help")) {
      usage(argp, "", 0);
    }

    Config config = CliOptions.getConfig(argp);
    final FsckOptions options = new FsckOptions(argp, config);
    final TSDB tsdb = new TSDB(config);
    final ArrayList<Query> queries = new ArrayList<Query>();
    if (args != null && args.length > 0) {
      CliQuery.parseCommandLineQuery(args, tsdb, queries, null, null);
    }
    if (queries.isEmpty() && !argp.has("--full-scan")) {
      usage(argp, "Must supply a query or use the '--full-scan' flag", 1);
    }
    tsdb.checkNecessaryTablesExist().joinUninterruptibly();

    argp = null;
    final Fsck fsck = new Fsck(tsdb, options);
    try {
      if (!queries.isEmpty()) {
        fsck.runQueries(queries);
      } else {
        fsck.runFullTable();
      }
    } finally {
      tsdb.shutdown().joinUninterruptibly();
    }
    System.exit(fsck.totalErrors() == 0 ? 0 : 1);
  }