Tabnine Logo
CLIContext
Code IndexAdd Tabnine to your IDE (free)

How to use
CLIContext
in
org.jpos.q2

Best Java code snippets using org.jpos.q2.CLIContext (Showing top 20 results out of 315)

origin: jpos/jPOS

  public void exec(CLIContext cli, String[] args)
  {
    cli.println("Type tab to see list of available commands");
    cli.println("Type 'man command-name' to see man page");
  }
}
origin: jpos/jPOS

  public void exec(CLIContext cli, String[] args) throws Exception {
    Terminal term = cli.getReader().getTerminal();
    cli.println("TERM=" + term.getClass().getSimpleName() + "/" + term.getType());
  }
}
origin: jpos/jPOS

public void exec(CLIContext cli, String[] args) throws IOException {
  boolean shutdown;
  if (cli.isInteractive() && cli.getOutputStream() != System.out) {
    cli.println ("Can't shutdown remotely");
    return;
  }
  if (hasOption(args, "-f", "--force", "-fq")) {
    shutdown = true;
  } else {
    shutdown = cli.confirm("Confirm shutdown (Yes/No) ? ");
  }
  if (shutdown) {
    if (!hasOption (args, "-q", "--quiet", "-fq"))
      cli.println("Shutting down.");
    cli.getCLI().getQ2().shutdown();
  } else {
    cli.println("Q2 will continue running.");
  }
}
origin: jpos/jPOS

private void showOne(CLIContext cli, String name, boolean detail) {
  try {
    Object obj = NameRegistrar.get(name);
    cli.println(name + " : " + obj.toString());
    if (detail && obj instanceof Loggeable) {
      cli.printLoggeable((Loggeable) obj, "");
    }
  }
  catch (NameRegistrar.NotFoundException e) {
    cli.println("Object not found in NameRegistrar");
  }
}
origin: jpos/jPOS-EE

@Override
public String getPrompt(CLIContext ctx, String[] args) {
  if (args.length < 2) {
    ctx.println ("Usage: binlog directory-name");
    return null;
  }
  ctx.getUserData().put("binlog", args[1]);
  return String.format("(%s)> ", new File(args[1]).getName());
}
origin: jpos/jPOS

  @Override
  public void exec(CLIContext ctx, String[] args) throws Exception {
    if (args.length < 2) {
      ctx.println("Usage: enable <xml_file(no extenssion)>");
      return;
    }        
    File deployDir = ctx.getCLI().getQ2().getDeployDir();		
    File deploy = new File(deployDir.getAbsolutePath()+"/"+args[1]+".xml");
    if(deploy.exists() && deploy.isFile()){
      File dest = new File(deployDir.getAbsolutePath()+"/"+args[1]+".xml.off");
      deploy.renameTo(dest);
      ctx.println("DISABLED: " + args[1]);
      return;
    }
    File dest = new File(deployDir.getAbsolutePath()+"/"+args[1]+".xml.off");
    if (dest.exists()) {
      ctx.println("Already disabled: " + args[1]);
      return;
    }
    ctx.println("Can't find the bean descriptor: "+args[1]);
    return;
  }
}
origin: jpos/jPOS

        if (cmd instanceof CLISubSystem) {
          CLISubSystem ss = (CLISubSystem) cmd;
          ctx.getCLI().setPrompt(ss.getPrompt(ctx, args), ss.getCompletionPrefixes(ctx, args));
          Terminal t = ctx.getReader().getTerminal();
          ((Command) cmd).exec (t.input(), t.output(), t.output(), args);
        ctx.printThrowable(ex);
    ctx.printThrowable(ex);
    break;
ctx.println("Invalid command '" + verbatimCmd + "'");
origin: jpos/jPOS-EE

  public void exec(CLIContext cli, String[] args) throws Exception {
    try (BinLogReader bl = new BinLogReader(new File((String) cli.getUserData().get("binlog")))) {
      while (bl.hasNext(10000L)) {
        BinLog.Entry ref = bl.next();
        cli.println(String.format("%06d@%08d %s",
         ref.ref().getFileNumber(),
         ref.ref().getOffset(),
         ISOUtil.hexdump(ref.get())));
        cli.getReader().getTerminal().flush();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
origin: jpos/jPOS

  public void exec(CLIContext cli, String[] args) throws Exception {
    if (args.length < 2) {
      cli.println("What manual page do you want?");
      return;
    }
    String command = args[1];
    InputStream is = getClass().getResourceAsStream(command.toUpperCase() + ".man");
    if (is != null) {
      try {
        byte[] b = new byte[is.available()];
        is.read(b);
        cli.print(new String(b));
      } finally {
        is.close();
      }
    } else {
      cli.println("No manual entry for " + command);
    }
  }
}
origin: jpos/jPOS

public boolean confirm(String prompt) {
  return "yes".equalsIgnoreCase(getReader().readLine(prompt));
}
origin: jpos/jPOS-EE

Terminal term= cli.getReader().getTerminal();
binding.setVariable("q2",   cli.getCLI().getQ2());
binding.setVariable("cli",  cli.getCLI());
binding.setVariable("out",  new PrintStream(out));  // PrintStream "out" in the Binding will redirect println()
binding.setVariable("err",  new PrintStream(err));
origin: jpos/jPOS

public void print(String s) {
  if (isInteractive())
    getReader().getTerminal().writer().print(s);
  else {
    try {
      out.write(s.getBytes());
      out.flush();
    } catch (IOException ignored) {
      ignored.printStackTrace();
    }
  }
}
origin: jpos/jPOS-EE

  private void showHelp (CLIContext cli, String args[], Options options) {
    PrintWriter pw = new PrintWriter (cli.getOutputStream());
    HelpFormatter helpFormatter = new HelpFormatter ();
    helpFormatter.printHelp (args[0] + "[options]", options);
    helpFormatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, args[0], null, options, 0, HelpFormatter.DEFAULT_DESC_PAD, null,false);
  }
}
origin: jpos/jPOS-EE

  public void exec(CLIContext cli, String[] args) throws Exception {
    boolean quiet = args.length > 1 && "-q".equals (args[1]);
    try (BinLogWriter bl = new BinLogWriter(new File((String) cli.getUserData().get("binlog")))) {
      int oldFile = bl.getFileNumber();
      bl.cutover();
      if (!quiet)
        cli.print (String.format ("cutover %06d -> %06d%n", oldFile, bl.getFileNumber()));
    }
  }
}
origin: jpos/jPOS

public void println(String s)  {
  print (s + System.getProperty("line.separator"));
}
origin: jpos/jPOS-EE

@Override
public String getPrompt(CLIContext ctx, String[] args) {
  String prefix = null;
  if (args.length > 1) {
    prefix = args[1];
    if (!prefix.endsWith("."))
      prefix  = prefix + ".";
    ctx.getUserData().put(PREFIX, prefix);
  } else {
    ctx.getUserData().remove(PREFIX);
  }
  return  "sysconfig" + (prefix != null ? "[" + args[1] + "]" : "") + "> ";
}
origin: jpos/jPOS

  @Override
  public void exec(CLIContext ctx, String[] args) throws Exception {
    if (args.length < 2) {
      ctx.println("Usage: enable <xml_file(no extenssion)>");
      return;
    }
    File deployDir = ctx.getCLI().getQ2().getDeployDir();
    File deploy = new File(deployDir.getAbsolutePath() + "/" + args[1] + ".xml.off");
    if (deploy.exists() && deploy.isFile()) {
      File dest = new File(deployDir.getAbsolutePath() + "/" + args[1] + ".xml");
      deploy.renameTo(dest);
      ctx.println("ENABLED: " + args[1]);
      return;
    }
    File dest = new File(deployDir.getAbsolutePath() + "/" + args[1] + ".xml");
    if (dest.exists()) {
      ctx.println("Already enabled: " + args[1]);
      return;
    }
    ctx.println("Can't find the bean descriptor: " + args[1]);
    return;
  }
}
origin: jpos/jPOS-EE

  @Override
  public void exec(CLIContext cli, String[] args) throws Exception {
    if (args.length < 2) {
      cli.println("Usage: rm <id> ");
      return;
    }
    try (DB db = new DB()) {
      db.open();
      db.beginTransaction();
      SysConfigManager mgr = new SysConfigManager(db);
      if (cli.getUserData().containsKey(SYSCONFIG.PREFIX))
        mgr.setPrefix((String) cli.getUserData().get(SYSCONFIG.PREFIX));
      boolean deleted = mgr.delete(args[1]);
      db.commit();
      cli.println ("sysconfig " + (deleted ? "deleted" : "not found"));
    } catch (Exception e) {
      cli.println (e.getMessage());
    }
  }
}
origin: jpos/jPOS

  private void showAll(CLIContext cli, boolean detail) {
    NameRegistrar nr = NameRegistrar.getInstance();
    int maxw = 0;
    Iterator iter = NameRegistrar.getAsMap().entrySet().iterator();
    while (iter.hasNext()) {
      Map.Entry entry = (Map.Entry) iter.next();
      maxw = Math.max(maxw, entry.getKey().toString().length());
    }
    iter = NameRegistrar.getAsMap().entrySet().iterator();
    maxw++;
    while (iter.hasNext()) {
      Map.Entry entry = (Map.Entry) iter.next();
      cli.println(
          ISOUtil.strpad(entry.getKey().toString(), maxw) +
          entry.getValue().toString()
      );
      if (detail && entry.getValue() instanceof Loggeable) {
        cli.printLoggeable((Loggeable) entry.getValue(), "   ");
      }
    }
  }
}
origin: jpos/jPOS

  public void exec(CLIContext ctx, String[] args) throws Exception {
    ctx.getReader().getTerminal().puts(InfoCmp.Capability.clear_screen);
  }
}
org.jpos.q2CLIContext

Most used methods

  • println
  • getReader
  • getOutputStream
  • getCLI
  • getUserData
  • print
  • <init>
  • builder
  • confirm
  • isInteractive
  • isStopped
  • printLoggeable
  • isStopped,
  • printLoggeable,
  • printThrowable,
  • setReader,
  • setStopped

Popular in Java

  • Creating JSON documents from java classes using gson
  • putExtra (Intent)
  • setContentView (Activity)
  • findViewById (Activity)
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now