当前位置: 首页>>代码示例>>Java>>正文


Java ConsoleReader.setHistory方法代码示例

本文整理汇总了Java中jline.console.ConsoleReader.setHistory方法的典型用法代码示例。如果您正苦于以下问题:Java ConsoleReader.setHistory方法的具体用法?Java ConsoleReader.setHistory怎么用?Java ConsoleReader.setHistory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jline.console.ConsoleReader的用法示例。


在下文中一共展示了ConsoleReader.setHistory方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildInstance

import jline.console.ConsoleReader; //导入方法依赖的package包/类
public static HeroicInteractiveShell buildInstance(
    final List<CommandDefinition> commands, FileInputStream input
) throws Exception {
    final ConsoleReader reader = new ConsoleReader("heroicsh", input, System.out, null);

    final FileHistory history = setupHistory(reader);

    if (history != null) {
        reader.setHistory(history);
    }

    reader.setPrompt(String.format("heroic> "));
    reader.addCompleter(new StringsCompleter(
        ImmutableList.copyOf(commands.stream().map((d) -> d.getName()).iterator())));
    reader.setHandleUserInterrupt(true);

    return new HeroicInteractiveShell(reader, commands, history);
}
 
开发者ID:spotify,项目名称:heroic,代码行数:19,代码来源:HeroicInteractiveShell.java

示例2: JLineDevice

import jline.console.ConsoleReader; //导入方法依赖的package包/类
public JLineDevice(InputStream in, PrintStream out) throws IOException {
    File hfile = new File(HFILE);
    if (!hfile.exists()) {
        File parentFile = hfile.getParentFile();
        if (!parentFile.exists()) {
            parentFile.mkdirs();
        }
        hfile.createNewFile();
    }
    writer = new PrintWriter(out, true);
    reader = new ConsoleReader(in, out);
    history = new FileHistory(hfile);
    reader.setHistory(history);

    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
        @Override
        public void run() {
            writeHistory();
        }
    }));
}
 
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:22,代码来源:JLineDevice.java

示例3: createConsoleReader

import jline.console.ConsoleReader; //导入方法依赖的package包/类
@Override
protected ConsoleReader createConsoleReader() {
  ConsoleReader consoleReader = super.createConsoleReader();
  consoleReader.setHistory(gfshHistory);
  terminal = consoleReader.getTerminal();
  return consoleReader;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:8,代码来源:Gfsh.java

示例4: start

import jline.console.ConsoleReader; //导入方法依赖的package包/类
public void start() throws Exception {
    console = new ConsoleReader();
    console.getTerminal().setEchoEnabled(false);
    console.setPrompt("\u001B[32menkan\u001B[0m> ");
    History history = new FileHistory(new File(System.getProperty("user.home"), ".enkan_history"));
    console.setHistory(history);

    CandidateListCompletionHandler handler = new CandidateListCompletionHandler();
    console.setCompletionHandler(handler);
    consoleHandler = new ConsoleHandler(console);
    clientThread.execute(consoleHandler);
    clientThread.shutdown();
}
 
开发者ID:kawasima,项目名称:enkan,代码行数:14,代码来源:ReplClient.java

示例5: testHistory

import jline.console.ConsoleReader; //导入方法依赖的package包/类
@Test
public void testHistory() throws IOException{
	
	ConsoleReader console= new ConsoleReader();
	//History history= new History(new File(System.getProperty("user.home") + File.separator + ".asciigenome_history"));
	History history= new MemoryHistory();
	history.add("foobar");
	history.add("baz");
	console.setHistory(history);
	System.out.println(console.getHistory());
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:12,代码来源:UtilsTest.java

示例6: setupHistory

import jline.console.ConsoleReader; //导入方法依赖的package包/类
private void setupHistory(ConsoleReader reader)
{
  File historyFile = new File(StramClientUtils.getUserDTDirectory(), "cli_history");
  historyFile.getParentFile().mkdirs();
  try {
    topLevelHistory = new FileHistory(historyFile);
    reader.setHistory(topLevelHistory);
    historyFile = new File(StramClientUtils.getUserDTDirectory(), "cli_history_clp");
    changingLogicalPlanHistory = new FileHistory(historyFile);
  } catch (IOException ex) {
    System.err.printf("Unable to open %s for writing.", historyFile);
  }
}
 
开发者ID:apache,项目名称:apex-core,代码行数:14,代码来源:ApexCli.java

示例7: execute

import jline.console.ConsoleReader; //导入方法依赖的package包/类
@Override
public void execute(String[] args, ConsoleReader reader) throws Exception
{
  logicalPlanRequestQueue.clear();
  changingLogicalPlan = false;
  reader.setHistory(topLevelHistory);
}
 
开发者ID:apache,项目名称:apex-core,代码行数:8,代码来源:ApexCli.java

示例8: run

import jline.console.ConsoleReader; //导入方法依赖的package包/类
private static void run() throws IOException {
    reader = new ConsoleReader();
    reader.addCompleter(new StringsCompleter("compileTest", "evalTest", "-acge", "getEnv()", "eval", "addKey"));

    FileHistory fileHistory = new FileHistory(new File("./sh/history.just"));
    reader.setHistoryEnabled(true);
    reader.setHistory(fileHistory);

    Runtime.getRuntime().addShutdownHook(new Thread(() -> {
        System.out.println("");
        System.out.println(ANSI_PURPLE + "Have a nice Day~~" + ANSI_RESET);
        try {
            fileHistory.flush();
        } catch (IOException ignored) {
        }
    }));

    String command;
    while ((command = reader.readLine(cyanPrint(JUST_EL))) != null) {

        if (command.equals("")) continue;
        else if (command.trim().equals("-q")) return;
        else if (resolveCommandLine(command)) continue;

        try {

            Queue<Token> tokens = lexer.scanner(command);

            reader.addCompleter(
                    new StringsCompleter(
                            tokens.stream()
                                  .map(Token::getText)
                                  .collect(toList())));

            AstNode node = parser.parser(tokens);

            if (openAst) {
                runAst(node);
            }

            if (openMockEval) {
                runEval(node, env);
            }

            if (openMockGenerate) {
                runCompile(node, env);
            }

        } catch (Throwable e) {
            AnsiConsole.out.println(ansi().fgRed().a(JUST_EL + e.getMessage()).reset().toString());
        }
    }
}
 
开发者ID:lfkdsk,项目名称:Just-Evaluator,代码行数:54,代码来源:JustRepl.java

示例9: Init

import jline.console.ConsoleReader; //导入方法依赖的package包/类
private void Init(String accnt, String key, String cont) throws IOException
{
    conReader = new ConsoleReader();
    conReader.setPrompt("AzureShell> ");
    
     List<Completer> completors = new LinkedList<>();
     
    String currFileNameStr = "dir1";

    AzFileProvider azfp = new AzFileProvider();
    StaticUserAuthenticator auth = new StaticUserAuthenticator("", accnt, key);
    AzFileSystemConfigBuilder.getInstance().setUserAuthenticator(azfp.getDefaultFileSystemOptions(), auth); 
    
    DefaultFileSystemManager currMan = new DefaultFileSystemManager();
    currMan.addProvider(AzConstants.AZSBSCHEME, azfp);
    currMan.addProvider("file", new DefaultLocalFileProvider());
    currMan.init(); 
    
    mgr = currMan;
    //cwd = mgr.resolveFile(System.getProperty("user.dir"));c
    String currAzURL = String.format("%s://%s/%s/%s", 
                       AzConstants.AZSBSCHEME, accnt, cont, currFileNameStr);
    cwd = mgr.resolveFile(currAzURL);
    
    completors.add(new FileNameCompleter());
    completors.add(new StringsCompleter(AzConstants.AZSBSCHEME, "file://", currAzURL));
    AggregateCompleter aggComp = new AggregateCompleter(completors);
    ArgumentCompleter argComp = new ArgumentCompleter(aggComp);
    argComp.setStrict(false);
    conReader.addCompleter(argComp);
    
    Path histPath = Paths.get(System.getProperty("user.home"), ".simpleshellhist");
    File histFile = histPath.toFile();
    FileHistory fh = new FileHistory(histFile);
    conReader.setHistory(fh);
    conReader.setHistoryEnabled(true);
    
    Runtime.getRuntime().addShutdownHook(
            new Thread() 
            {
                @Override
                public void run() 
                {
                    try
                    {
                        ((FileHistory)conReader.getHistory()).flush();
                    }
                    catch (IOException ex)
                    {
                        log.error("Error saving history", ex);
                    }
                }
            });
    
}
 
开发者ID:kervinpierre,项目名称:vfs-azure,代码行数:56,代码来源:SimpleShell.java


注:本文中的jline.console.ConsoleReader.setHistory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。