Package org.eclipse.jgit.pgm.opt

Examples of org.eclipse.jgit.pgm.opt.CmdLineParser


     *          the error stream, may be null in which case the system error stream will be used
     * @throws Exception
     *          if an error occurs
     */
    public void execute(final String[] argv, InputStream in, OutputStream out, OutputStream err) throws Exception {
        final CmdLineParser clp = new CmdLineParser(this);
        PrintWriter writer = new PrintWriter(err != null ? err : System.err);
        try {
            clp.parseArgument(argv);
        } catch (CmdLineException e) {
            if (argv.length > 0 && !help) {
                writer.println(MessageFormat.format(CLIText.get().fatalError, e.getMessage()));
                writer.flush();
                throw new Die(true);
            }
        }

        if (argv.length == 0 || help) {
            final String ex = clp.printExample(ExampleMode.ALL, CLIText.get().resourceBundle());
            writer.println("jgit" + ex + " command [ARG ...]"); //$NON-NLS-1$
            if (help) {
                writer.println();
                clp.printUsage(writer, CLIText.get().resourceBundle());
                writer.println();
            } else if (subcommand == null) {
                writer.println();
                writer.println(CLIText.get().mostCommonlyUsedCommandsAre);
                final CommandRef[] common = CommandCatalog.common();
View Full Code Here


   *
   * @param args
   *            the arguments supplied on the command line, if any.
   */
  protected void parseArguments(final String[] args) {
    final CmdLineParser clp = new CmdLineParser(this);
    try {
      clp.parseArgument(args);
    } catch (CmdLineException err) {
      if (!help) {
        System.err.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage()));
        System.exit(1);
      }
    }

    if (help) {
      printUsageAndExit(clp);
    }

    argWalk = clp.getRevWalkGently();
  }
View Full Code Here

      System.exit(1);
    }
  }

  private void execute(final String[] argv) throws Exception {
    final CmdLineParser clp = new CmdLineParser(this);
    PrintWriter writer = new PrintWriter(System.err);
    try {
      clp.parseArgument(argv);
    } catch (CmdLineException err) {
      if (argv.length > 0 && !help) {
        writer.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage()));
        writer.flush();
        System.exit(1);
      }
    }

    if (argv.length == 0 || help) {
      final String ex = clp.printExample(ExampleMode.ALL, CLIText.get().resourceBundle());
      writer.println("jgit" + ex + " command [ARG ...]"); //$NON-NLS-1$
      if (help) {
        writer.println();
        clp.printUsage(writer, CLIText.get().resourceBundle());
        writer.println();
      } else if (subcommand == null) {
        writer.println();
        writer.println(CLIText.get().mostCommonlyUsedCommandsAre);
        final CommandRef[] common = CommandCatalog.common();
View Full Code Here

  protected void run() throws Exception {
    if (delete || deleteForce)
      delete(deleteForce);
    else {
      if (branches.size() > 2)
        throw die(CLIText.get().tooManyRefsGiven + new CmdLineParser(this).printExample(ExampleMode.ALL));

      if (rename) {
        String src, dst;
        if (branches.size() == 1) {
          final Ref head = db.getRef(Constants.HEAD);
View Full Code Here

   * @param args
   *            the arguments supplied on the command line, if any.
   * @throws IOException
   */
  protected void parseArguments(final String[] args) throws IOException {
    final CmdLineParser clp = new CmdLineParser(this);
    try {
      clp.parseArgument(args);
    } catch (CmdLineException err) {
      if (!help) {
        this.errw.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage()));
        throw die(true);
      }
    }

    if (help) {
      printUsageAndExit(clp);
    }

    argWalk = clp.getRevWalkGently();
  }
View Full Code Here

      System.exit(1);
    }
  }

  private void execute(final String[] argv) throws Exception {
    final CmdLineParser clp = new CmdLineParser(this);
    PrintWriter writer = new PrintWriter(System.err);
    try {
      clp.parseArgument(argv);
    } catch (CmdLineException err) {
      if (argv.length > 0 && !help && !version) {
        writer.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage()));
        writer.flush();
        System.exit(1);
      }
    }

    if (argv.length == 0 || help) {
      final String ex = clp.printExample(ExampleMode.ALL, CLIText.get().resourceBundle());
      writer.println("jgit" + ex + " command [ARG ...]"); //$NON-NLS-1$
      if (help) {
        writer.println();
        clp.printUsage(writer, CLIText.get().resourceBundle());
        writer.println();
      } else if (subcommand == null) {
        writer.println();
        writer.println(CLIText.get().mostCommonlyUsedCommandsAre);
        final CommandRef[] common = CommandCatalog.common();
View Full Code Here

  protected void run() throws Exception {
    if (delete || deleteForce)
      delete(deleteForce);
    else {
      if (branches.size() > 2)
        throw die(CLIText.get().tooManyRefsGiven + new CmdLineParser(this).printExample(ExampleMode.ALL));

      if (rename) {
        String src, dst;
        if (branches.size() == 1) {
          final Ref head = db.getRef(Constants.HEAD);
View Full Code Here

          "Expected 'git <command> [<args>]', was:" + str);
    String[] argv = new String[args.length - 1];
    System.arraycopy(args, 1, argv, 0, args.length - 1);

    CLIGitCommand bean = new CLIGitCommand();
    final CmdLineParser clp = new CmdLineParser(bean);
    clp.parseArgument(argv);

    final TextBuiltin cmd = bean.getSubcommand();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    cmd.outs = baos;
    if (cmd.requiresRepository())
View Full Code Here

  protected void run() throws Exception {
    if (delete || deleteForce)
      delete(deleteForce);
    else {
      if (branches.size() > 2)
        throw die(CLIText.get().tooManyRefsGiven + new CmdLineParser(this).printExample(ExampleMode.ALL));

      if (rename) {
        String src, dst;
        if (branches.size() == 1) {
          final Ref head = db.getRef(Constants.HEAD);
View Full Code Here

   *
   * @param args
   *            the arguments supplied on the command line, if any.
   */
  protected void parseArguments(final String[] args) {
    final CmdLineParser clp = new CmdLineParser(this);
    try {
      clp.parseArgument(args);
    } catch (CmdLineException err) {
      if (!help) {
        System.err.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage()));
        System.exit(1);
      }
    }

    if (help) {
      printUsageAndExit(clp);
    }

    argWalk = clp.getRevWalkGently();
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.pgm.opt.CmdLineParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.