Package net.sourceforge.argparse4j.inf

Examples of net.sourceforge.argparse4j.inf.Subparsers


    @Test
    public void testSubparserFormatHelpWithDefaultHelp()
            throws ArgumentParserException {
        ap.addArgument("--bar");
        Subparsers subparsers = ap.addSubparsers();
        Subparser parser = subparsers.addParser("install").defaultHelp(true);
        parser.addArgument("--foo").setDefault("alpha");
        assertEquals(String.format(
                  TextHelper.LOCALE_ROOT,
                  "usage: argparse4j install [-h] [--foo FOO]%n"
                + "%n"
View Full Code Here


    }

    @Test
    public void testFormatHelpWithSubparserTitleDescription()
            throws ArgumentParserException {
        Subparsers subparsers = ap.addSubparsers().help("subcommand help")
                .title("mysubcommands").description("valid subcommands");
        subparsers.addParser("install").help("install help");
        assertEquals(String.format(
                  TextHelper.LOCALE_ROOT,
                  "usage: argparse4j [-h] {install} ...%n"
                + "%n"
                + "optional arguments:%n"
View Full Code Here

    }

    @Test
    public void testFormatHelpWithSubparserAlias()
            throws ArgumentParserException {
        Subparsers subparsers = ap.addSubparsers().help("subcommand help")
                .title("mysubcommands").description("valid subcommands");
        subparsers.addParser("clone").help("clone help");
        subparsers.addParser("checkout").aliases("co").help("checkout help");
        subparsers.addParser("remove").aliases("rm","del").help("remove help");
        assertEquals(String.format(
                  TextHelper.LOCALE_ROOT,
                  "usage: argparse4j [-h] {clone,checkout,co,remove,rm,del} ...%n"
                + "%n"
                + "optional arguments:%n"
View Full Code Here

        ap.addArgument("-f", "--foo").help(h);
        ap.addArgument("-1", "--1").metavar("X").nargs(2).help(h);
        ap.addArgument("-2").metavar("X").nargs("*").help(h);
        ap.addArgument("-3").metavar("X").nargs("+").help(h);
        ap.addArgument("-4").metavar("X").nargs("?").help(h);
        Subparsers subparsers = ap.addSubparsers().help("sub-command help");
        Subparser parserA = subparsers.addParser("install");
        parserA.help("parserA help");
        Subparser parserB = subparsers.addParser("search");

        // StringWriter out = new StringWriter();
        ap.printHelp(new PrintWriter(System.out));
    }
View Full Code Here

      "descriptions,... Can be : en-EN, en-US, tr-TR, fr-FR ... (default : en-EN)").setDefault(FeatureControl.SUPPRESS);
  parser.addArgument("-a", "--host").nargs("?").help("Proxy host").setDefault(FeatureControl.SUPPRESS);
  parser.addArgument("-l", "--port").type(Integer.class).nargs("?").help("Proxy port")
    .setDefault(FeatureControl.SUPPRESS);

  Subparsers subparsers = parser.addSubparsers().description("Command to be executed.");

  /* =================Download Arguments============== */
  Subparser downloadParser = subparsers.addParser("download", true).description("download file(s)!")
    .setDefault("command", COMMAND.DOWNLOAD);
  downloadParser.addArgument("packagename").nargs("+").help("applications to download");

  /* =================Check-In Arguments============== */
  subparsers.addParser("checkin", true).description("checkin section!").setDefault("command", COMMAND.CHECKIN);

  /* =================List Arguments============== */
  Subparser listParser = subparsers.addParser("list", true)
    .description("Lists sub-categories and applications within them!").setDefault("command", COMMAND.LIST);
  listParser.addArgument("category").required(true).help("defines category");
  listParser.addArgument("-s", "--subcategory").required(false).help("defines sub-category");
  listParser.addArgument("-o", "--offset").type(Integer.class).required(false)
    .help("offset to define where list begins");
  listParser.addArgument("-n", "--number").type(Integer.class).required(false)
    .help("how many app will be listed");

  /* =================Categories Arguments============== */
  Subparser categoriesParser = subparsers.addParser("categories", true)
    .description("list categories for browse section").setDefault("command", COMMAND.CATEGORIES);

  /* =================Search Arguments============== */
  Subparser searchParser = subparsers.addParser("search", true).description("search for query!")
    .setDefault("command", COMMAND.SEARCH);
  searchParser.addArgument("query").help("query to be searched");
  searchParser.addArgument("-o", "--offset").type(Integer.class).required(false)
    .help("offset to define where list begins");
  searchParser.addArgument("-n", "--number").type(Integer.class).required(false)
    .help("how many app will be listed");

  /* =================Permissions Arguments============== */
  Subparser permissionsParser = subparsers.addParser("permissions", true)
    .description("list permissions of given application").setDefault("command", COMMAND.PERMISSIONS);
  permissionsParser.addArgument("package").nargs("+").help("applications whose permissions to be listed");

  /* =================Reviews Arguments============== */
  Subparser reviewsParser = subparsers.addParser("reviews", true)
    .description("lists reviews of given application").setDefault("command", COMMAND.REVIEWS);
  reviewsParser.addArgument("package").help("application whose reviews to be listed");
  reviewsParser.addArgument("-s", "--sort").choices(new ReviewSortChoice()).type(new ReviewSort())
    .required(false).help("sorting type").setDefault(REVIEW_SORT.HELPFUL);
  reviewsParser.addArgument("-o", "--offset").type(Integer.class).required(false)
    .help("offset to define where list begins");
  reviewsParser.addArgument("-n", "--number").type(Integer.class).required(false)
    .help("how many reviews will be listed");
 
  /* =================Recommendation Arguments============== */
  Subparser recommendationParser = subparsers.addParser("recommendations", true)
    .description("lists recommended apps of given application").setDefault("command", COMMAND.RECOMMENDATIONS);
  recommendationParser.addArgument("package").help("application whose recommendations to be listed");
  recommendationParser.addArgument("-t", "--type").choices(new ReleationChoice()).type(new RecommendationType())
    .required(false).help("releations type").setDefault(RECOMMENDATION_TYPE.ALSO_INSTALLED);
  recommendationParser.addArgument("-o", "--offset").type(Integer.class).required(false)
    .help("offset to define where list begins");
  recommendationParser.addArgument("-n", "--number").type(Integer.class).required(false)
    .help("how many recommendations will be listed");
 
  /* =================Register Arguments============== */
  subparsers.addParser("register", true).description("registers device so that can be seen from web!")
    .setDefault("command", COMMAND.REGISTER);
 
  /* =================UseGCM Arguments============== */
  subparsers.addParser("usegcm", true).description("listens GCM(GoogleCloudMessaging) for download notification and downloads them!")
    .setDefault("command", COMMAND.USEGCM);
    }
View Full Code Here

     * @param args the arguments from the command line input
     * @return true if two inputs were read with no differences, false if differences were found or an error was encountered
     */
    protected static boolean runJolt( String[] args ) {
        ArgumentParser parser = ArgumentParsers.newArgumentParser( "jolt" );
        Subparsers subparsers = parser.addSubparsers().help( "transform: given a Jolt transform spec, runs the specified transforms on the input data.\n" +
                "diffy: diff two JSON documents.\n" +
                "sort: sort a JSON document alphabetically for human readability." );

        for ( Map.Entry<String, JoltCliProcessor> entry : JOLT_CLI_PROCESSOR_MAP.entrySet() ) {
            entry.getValue().intializeSubCommand( subparsers );
View Full Code Here

TOP

Related Classes of net.sourceforge.argparse4j.inf.Subparsers

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.