當前位置: 首頁>>代碼示例>>Java>>正文


Java ConsoleReader類代碼示例

本文整理匯總了Java中jline.console.ConsoleReader的典型用法代碼示例。如果您正苦於以下問題:Java ConsoleReader類的具體用法?Java ConsoleReader怎麽用?Java ConsoleReader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ConsoleReader類屬於jline.console包,在下文中一共展示了ConsoleReader類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: CloudConfig

import jline.console.ConsoleReader; //導入依賴的package包/類
public CloudConfig(ConsoleReader consoleReader) throws Exception
{
    if (!Files.exists(Paths.get("local"))) Files.createDirectory(Paths.get("local"));
    if (!Files.exists(Paths.get("local/libs"))) Files.createDirectory(Paths.get("local/libs"));
    if (!Files.exists(Paths.get("local/templates"))) Files.createDirectory(Paths.get("local/templates"));
    if (!Files.exists(Paths.get("local/plugins"))) Files.createDirectory(Paths.get("local/plugins"));
    if (!Files.exists(Paths.get("local/cache"))) Files.createDirectory(Paths.get("local/cache"));
    if (!Files.exists(Paths.get("local/servers"))) Files.createDirectory(Paths.get("local/servers"));
    if (!Files.exists(Paths.get("local/servers/TestServer")))
        Files.createDirectory(Paths.get("local/servers/TestServer"));
    if (!Files.exists(Paths.get("local/servers/TestServer/plugins")))
        Files.createDirectory(Paths.get("local/servers/TestServer/plugins"));

    NetworkUtils.writeWrapperKey();

    defaultInit(consoleReader);
    defaultInitDoc(consoleReader);
    defaultInitUsers(consoleReader);
    load();
}
 
開發者ID:Dytanic,項目名稱:CloudNet,代碼行數:21,代碼來源:CloudConfig.java

示例2: defaultInitDoc

import jline.console.ConsoleReader; //導入依賴的package包/類
private void defaultInitDoc(ConsoleReader consoleReader) throws Exception
{
    if (Files.exists(servicePath)) return;

    String hostName = NetworkUtils.getHostName();
    if (hostName.equals("127.0.0.1") || hostName.equalsIgnoreCase("127.0.1.1") || hostName.split("\\.").length != 4)
    {
        String input;
        System.out.println("Please write the first Wrapper IP address:");
        while ((input = consoleReader.readLine()) != null)
        {
            if ((input.equals("127.0.0.1") || input.equalsIgnoreCase("127.0.1.1") || input.split("\\.").length != 4))
            {
                System.out.println("Please write the real ip address :)");
                continue;
            }

            hostName = input;
            break;
        }
    }
    new Document("wrapper", Arrays.asList(new WrapperMeta("Wrapper-1", hostName, "admin")))
            .append("serverGroups", Arrays.asList(new LobbyGroup()))
            .append("proxyGroups", Arrays.asList(new BungeeGroup()))
            .saveAsConfig(servicePath);
}
 
開發者ID:Dytanic,項目名稱:CloudNet,代碼行數:27,代碼來源:CloudConfig.java

示例3: format

import jline.console.ConsoleReader; //導入依賴的package包/類
@Override
public String format(LogRecord record)
{
    StringBuilder builder = new StringBuilder();
    if (record.getThrown() != null)
    {
        StringWriter writer = new StringWriter();
        record.getThrown().printStackTrace(new PrintWriter(writer));
        builder.append(writer).append("\n");
    }

    StringBuilder stringBuilder = new StringBuilder(ConsoleReader.RESET_LINE)
            .append("[")
            .append(format.format(System.currentTimeMillis()))
            .append("/")
            .append(name)
            .append("] ")
            .append(record.getLevel().getName())
            .append(": ")
            .append(formatMessage(record))
            .append("\n").append(builder.substring(0));

    return stringBuilder.substring(0);
}
 
開發者ID:Dytanic,項目名稱:CloudNet,代碼行數:25,代碼來源:CloudLogger.java

示例4: CommandReader

import jline.console.ConsoleReader; //導入依賴的package包/類
public CommandReader() {
    if (instance != null) {
        throw new RuntimeException("CommandReader is already initialized!");
    }
    try {
        this.reader = new ConsoleReader();
        reader.setPrompt("> ");
        instance = this;

        reader.addCompleter(new PlayersCompleter()); // Add player TAB completer
        reader.addCompleter(new CommandsCompleter()); // Add command TAB completer
    } catch (IOException e) {
        Server.getInstance().getLogger().error("Unable to start CommandReader", e);
    }
    this.setName("Console");
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:17,代碼來源:CommandReader.java

示例5: complete

import jline.console.ConsoleReader; //導入依賴的package包/類
public boolean complete(ConsoleReader reader, List<CharSequence> candidates, int pos) throws IOException {
    CursorBuffer buf = reader.getCursorBuffer();
    if(candidates.size() == 1) {
        CharSequence value1 = (CharSequence) candidates.get(0);
        if(value1.equals(buf.toString())) {
            return false;
        }
        else {
            setBuffer(reader, value1, pos);
            return true;
        }
    }
    else {
        if(candidates.size() > 1) {
            String value = this.getUnambiguousCompletions(candidates);
            setBuffer(reader, value, pos);
        }

        printCandidates(reader, candidates);
        reader.drawLine();
        return true;
    }
}
 
開發者ID:Superioz,項目名稱:MooProject,代碼行數:24,代碼來源:CandidateCompletionHandler.java

示例6: CommandReader

import jline.console.ConsoleReader; //導入依賴的package包/類
public CommandReader() {
    if (instance != null) {
        throw new RuntimeException("CommandReader is already initialized!");
    }
    try {
        this.reader = new ConsoleReader();
        reader.setPrompt("> ");
        instance = this;
        
        reader.addCompleter(new PlayersCompleter()); // Add player TAB completer
        reader.addCompleter(new CommandsCompleter()); // Add command TAB completer
    } catch (IOException e) {
        Server.getInstance().getLogger().error("Unable to start CommandReader", e);
    }
    this.setName("Console");
}
 
開發者ID:JupiterDevelopmentTeam,項目名稱:Jupiter,代碼行數:17,代碼來源:CommandReader.java

示例7: compute

import jline.console.ConsoleReader; //導入依賴的package包/類
@Override
public FixResult compute(TryJShellTool repl, String code, int cursor) {
    String type = repl.analysis.analyzeType(code, cursor);
    if (type == null) {
        return new FixResult(Collections.emptyList(), null);
    }
    return new FixResult(Collections.singletonList(new Fix() {
        @Override
        public String displayName() {
            return "Create variable";
        }
        @Override
        public void perform(ConsoleReader in) throws IOException {
            in.redrawLine();
            in.setCursorPosition(0);
            in.putString(type + "  = ");
            in.setCursorPosition(in.getCursorBuffer().cursor - 3);
            in.flush();
        }
    }), null);
}
 
開發者ID:kawasima,項目名稱:try-artifact,代碼行數:22,代碼來源:ConsoleIOContext.java

示例8: JLineTextTerminal

import jline.console.ConsoleReader; //導入依賴的package包/類
public JLineTextTerminal(ConsoleReader reader) {
    if(reader == null) throw new IllegalArgumentException("reader is null");
    reader.setHandleUserInterrupt(true);
    this.reader = reader;

    TerminalProperties<JLineTextTerminal> props = getProperties();
    props.addStringListener(PROP_PROMPT_COLOR, null, (term, newVal) -> setPromptColor(newVal));
    props.addStringListener(PROP_PROMPT_BGCOLOR, null, (term, newVal) -> setPromptBackgroundColor(newVal));
    props.addBooleanListener(PROP_PROMPT_BOLD, false, (term, newVal) -> setPromptBold(newVal));
    props.addBooleanListener(PROP_PROMPT_ITALIC, false, (term, newVal) -> setPromptItalic(newVal));
    props.addBooleanListener(PROP_PROMPT_UNDERLINE, false, (term, newVal) -> setPromptUnderline(newVal));
    props.addStringListener(PROP_INPUT_COLOR, null, (term, newVal) -> setInputColor(newVal));
    props.addStringListener(PROP_INPUT_BGCOLOR, null, (term, newVal) -> setInputBackgroundColor(newVal));
    props.addBooleanListener(PROP_INPUT_BOLD, false, (term, newVal) -> setInputBold(newVal));
    props.addBooleanListener(PROP_INPUT_ITALIC, false, (term, newVal) -> setInputItalic(newVal));
    props.addBooleanListener(PROP_INPUT_UNDERLINE, false, (term, newVal) -> setInputUnderline(newVal));

    props.addStringListener(PROP_ANSI_COLOR_MODE, AnsiColorMode.STANDARD.toString(), (term, newVal) -> setAnsiColorMode(newVal));
}
 
開發者ID:beryx,項目名稱:text-io,代碼行數:20,代碼來源:JLineTextTerminal.java

示例9: JaPSLogger

import jline.console.ConsoleReader; //導入依賴的package包/類
public JaPSLogger(ConsoleReader consoleReader) {

        super("JaPS", null);
        setLevel(Level.INFO);

        try {
            File logDir = new File("logs");
            if (!logDir.exists()) {
                if (!logDir.mkdir()) {
                    log(Level.SEVERE, "Unable to create 'logs' folder");
                }
            }

            FileHandler fileHandler = new FileHandler("logs" + File.separator + "japs.log", 1400000, 4, false);
            fileHandler.setFormatter(formatter);
            addHandler(fileHandler);

            ConsoleHandler consoleHandler = new ConsoleHandler(consoleReader);
            consoleHandler.setFormatter(formatter);
            addHandler(consoleHandler);
        } catch (IOException e) {
            e.printStackTrace();
        }

        dispatcher.start();
    }
 
開發者ID:JackWhite20,項目名稱:JaPS,代碼行數:27,代碼來源:JaPSLogger.java

示例10: GraqlShell

import jline.console.ConsoleReader; //導入依賴的package包/類
/**
 * Create a new Graql shell
 */
GraqlShell(
        String historyFilename, Keyspace keyspace,
        GraqlClient client, URI uri, String outputFormat, boolean infer
) throws Throwable {

    this.historyFilename = historyFilename;
    console = new ConsoleReader(System.in, System.out);
    session = new JsonSession(client, uri);

    // Send the requested keyspace and output format to the server once connected
    Json initJson = Json.object(
            ACTION, ACTION_INIT,
            KEYSPACE, keyspace.getValue(),
            OUTPUT_FORMAT, outputFormat,
            INFER, infer
    );
    session.sendJson(initJson);

    // Wait to receive confirmation
    handleMessagesFromServer();
}
 
開發者ID:graknlabs,項目名稱:grakn,代碼行數:25,代碼來源:GraqlShell.java

示例11: increasePop

import jline.console.ConsoleReader; //導入依賴的package包/類
/**
 * Raise population of hippopotamus amphibius within console.
 * @param console
 */
public static void increasePop(ConsoleReader console) {
    HippopotamusFactory builder = HippopotamusFactory.builder();

    if (System.getenv("HIPPO_SIZE") != null) {
        int hippoSize = Integer.parseInt(System.getenv("HIPPO_SIZE"));
        builder.size(hippoSize);
    }

    Hippopotamus hippo = builder.build();

    try {
        for (double i = 0; i < Math.PI; i += 0.1) {
            console.println(hippo.toString().replaceAll("^|\n", "\n" + StringUtils.repeat(" ", (int) (Math.sin(i) * 100))));
            console.flush();
            Thread.sleep(100);
        }
    } catch (IOException | InterruptedException e) {
        System.err.println("Supercalafrajilistichippopotamusexception");
    }

    hippo.submerge();

    console.setPrompt(hippo.toString());
}
 
開發者ID:graknlabs,項目名稱:grakn,代碼行數:29,代碼來源:HippopotamusFactory.java

示例12: run

import jline.console.ConsoleReader; //導入依賴的package包/類
@Override
public void run()
{
    if (! CoreMain.isConsoleEnabled())
    {
        return;
    }
    final ConsoleReader reader = this.core.getReader();
    try
    {
        while (this.core.isRunning())
        {
            final String line = CoreMain.isUseJline() ? reader.readLine(">", null) : reader.readLine();
            if ((line == null) || (line.trim().length() <= 0))
            {
                continue;
            }
            EventType.callEvent(new SenderCommandEvent(this.core.getConsoleSender(), line));
        }
    } catch (final NoSuchElementException ignored)
    {
    } catch (final IOException e)
    {
        e.printStackTrace();
    }
}
 
開發者ID:Diorite,項目名稱:Diorite-old,代碼行數:27,代碼來源:ConsoleReaderThread.java

示例13: CommandCompleter

import jline.console.ConsoleReader; //導入依賴的package包/類
public CommandCompleter(ConsoleReader consoleReader,
		ArgumentDelimiter argumentDelimiter, Iterable<Command> commands) {
	this.console = consoleReader;
	List<String> names = new ArrayList<String>();
	for (Command command : commands) {
		this.commands.add(command);
		names.add(command.getName());
		List<String> options = new ArrayList<String>();
		for (OptionHelp optionHelp : command.getOptionsHelp()) {
			options.addAll(optionHelp.getOptions());
		}
		AggregateCompleter argumentCompleters = new AggregateCompleter(
				new StringsCompleter(options), new FileNameCompleter());
		ArgumentCompleter argumentCompleter = new ArgumentCompleter(argumentDelimiter,
				argumentCompleters);
		argumentCompleter.setStrict(false);
		this.commandCompleters.put(command.getName(), argumentCompleter);
	}
	getStrings().addAll(names);
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:21,代碼來源:CommandCompleter.java

示例14: readHost

import jline.console.ConsoleReader; //導入依賴的package包/類
private static String readHost(ConsoleReader reader, PrintWriter out, String prompt) {
  try {
    String inputString = readInputString(reader, out, prompt);

    if (InetAddresses.isInetAddress(inputString)) {
      return inputString;
    }
    out.println("Error, " + inputString + " is not a valid inet address");
  } catch (Exception exp) {
    if (WorfCLI.verbose) {
      exp.printStackTrace();
    }
    out.println("Error, unable to read the host. error=" + exp.getMessage());
  }
  return null;
}
 
開發者ID:cityzendata,項目名稱:warp10-platform,代碼行數:17,代碼來源:WorfInteractive.java

示例15: readInteger

import jline.console.ConsoleReader; //導入依賴的package包/類
private static String readInteger(ConsoleReader reader, PrintWriter out, String prompt) {
  try {
    String inputString = readInputString(reader, out, prompt);

    if (NumberUtils.isNumber(inputString)) {
      return inputString;
    }

    if (InetAddresses.isInetAddress(inputString)) {
      return inputString;
    }
    out.println("Error, " + inputString + " is not a number");
  } catch (Exception exp) {
    if (WorfCLI.verbose) {
      exp.printStackTrace();
    }
    out.println("Error, unable to read the host. error=" + exp.getMessage());
  }
  return null;
}
 
開發者ID:cityzendata,項目名稱:warp10-platform,代碼行數:21,代碼來源:WorfInteractive.java


注:本文中的jline.console.ConsoleReader類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。