Java Code Examples for org.jline.utils.AttributedString#stripAnsi()

The following examples show how to use org.jline.utils.AttributedString#stripAnsi() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PicocliCommands.java    From picocli with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param args
 * @return command description for JLine TailTipWidgets to be displayed in terminal status bar.
 */
@Override
public CmdDesc commandDescription(List<String> args) {
    CommandLine sub = findSubcommandLine(args, args.size());
    if (sub == null) {
        return null;
    }
    CommandSpec spec = sub.getCommandSpec();
    Help cmdhelp= new picocli.CommandLine.Help(spec);
    List<AttributedString> main = new ArrayList<>();
    Map<String, List<AttributedString>> options = new HashMap<>();
    String synopsis = AttributedString.stripAnsi(spec.usageMessage().sectionMap().get("synopsis").render(cmdhelp).toString());
    main.add(HelpException.highlightSyntax(synopsis.trim(), HelpException.defaultStyle()));
    // using JLine help highlight because the statement below does not work well...
    //        main.add(new AttributedString(spec.usageMessage().sectionMap().get("synopsis").render(cmdhelp).toString()));
    for (OptionSpec o : spec.options()) {
        String key = Arrays.stream(o.names()).collect(Collectors.joining(" "));
        List<AttributedString> val = new ArrayList<>();
        for (String d:  o.description()) {
            val.add(new AttributedString(d));
        }
        if (o.arity().max() > 0) {
            key += "=" + o.paramLabel();
        }
        options.put(key, val);
    }
    return new CmdDesc(main, ArgDesc.doArgNames(Arrays.asList("")), options);
}
 
Example 2
Source File: PicocliCommands.java    From picocli with Apache License 2.0 5 votes vote down vote up
@Override
public List<String> commandInfo(String command) {
    List<String> out = new ArrayList<>();
    CommandSpec spec = cmd.getSubcommands().get(command).getCommandSpec();
    Help cmdhelp = new picocli.CommandLine.Help(spec);
    String description = AttributedString.stripAnsi(spec.usageMessage().sectionMap().get("description").render(cmdhelp).toString());
    out.addAll(Arrays.asList(description.split("\\r?\\n")));
    return out;
}
 
Example 3
Source File: SqlCompleter.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
private Candidate createCandidate(String hint) {
	return new Candidate(AttributedString.stripAnsi(hint), hint, null, null, null, null, true);
}
 
Example 4
Source File: SqlCompleter.java    From flink with Apache License 2.0 4 votes vote down vote up
private Candidate createCandidate(String hint) {
	return new Candidate(AttributedString.stripAnsi(hint), hint, null, null, null, null, true);
}
 
Example 5
Source File: SqlCompleter.java    From flink with Apache License 2.0 4 votes vote down vote up
private Candidate createCandidate(String hint) {
	return new Candidate(AttributedString.stripAnsi(hint), hint, null, null, null, null, true);
}