private static void cmdPublicizeResources(CommandLine cli) throws AndrolibException { int paraCount = cli.getArgList().size(); String apkName = cli.getArgList().get(paraCount - 1); new Androlib().publicizeResources(new File(apkName)); }
private static void cmdInstallFramework(CommandLine cli) throws AndrolibException { int paraCount = cli.getArgList().size(); String apkName = cli.getArgList().get(paraCount - 1); ApkOptions apkOptions = new ApkOptions(); if (cli.hasOption("p") || cli.hasOption("frame-path")) { apkOptions.frameworkFolderLocation = cli.getOptionValue("p"); } if (cli.hasOption("t") || cli.hasOption("tag")) { apkOptions.frameworkTag = cli.getOptionValue("t"); } new Androlib(apkOptions).installFramework(new File(apkName)); }
@Override public int run(CommandLine cl) throws AlluxioException, IOException { String[] args = cl.getArgs(); String srcPath = args[0]; cl.getArgList().set(0, "file://" + new File(srcPath).getAbsolutePath()); mCpCommand.run(cl); return 0; }
@Override public int run(CommandLine cl) throws AlluxioException, IOException { String[] args = cl.getArgs(); String dst = args[1]; cl.getArgList().set(1, "file://" + new File(dst).getAbsolutePath()); mCpCommand.run(cl); return 0; }
private void dumpPluginOutput(InputStream input, PrintStream out, PrintStream err, CommandLine parsedArgs) throws DumpException { List<String> args = new ArrayList(parsedArgs.getArgList()); if (args.size() < 1) { throw new DumpException("Expected plugin argument"); } String pluginName = args.remove(0); DumperPlugin plugin = mDumperPlugins.get(pluginName); if (plugin == null) { throw new DumpException("No plugin named '" + pluginName + "'"); } DumperContext dumperContext = new DumperContext(input, out, err, mParser, args); plugin.dump(dumperContext); }
@Test public void testStopAtUnexpectedArg() throws Exception { String[] args = new String[] { "-c", "foober", "-b", "toast" }; CommandLine cl = parser.parse(options, args, true); assertTrue("Confirm -c is set", cl.hasOption("c")); assertTrue("Confirm 3 extra args: " + cl.getArgList().size(), cl.getArgList().size() == 3); }
@Test public void testStopAtNonOptionShort() throws Exception { String[] args = new String[]{"-z", "-a", "-btoast"}; CommandLine cl = parser.parse(options, args, true); assertFalse("Confirm -a is not set", cl.hasOption("a")); assertTrue("Confirm 3 extra args: " + cl.getArgList().size(), cl.getArgList().size() == 3); }
@Test public void testStopBursting() throws Exception { String[] args = new String[] { "-azc" }; CommandLine cl = parser.parse(options, args, true); assertTrue( "Confirm -a is set", cl.hasOption("a") ); assertFalse( "Confirm -c is not set", cl.hasOption("c") ); assertTrue( "Confirm 1 extra arg: " + cl.getArgList().size(), cl.getArgList().size() == 1); assertTrue(cl.getArgList().contains("zc")); }
@Test public void testStopAtExpectedArg() throws Exception { String[] args = new String[]{"-b", "foo"}; CommandLine cl = parser.parse(options, args, true); assertTrue("Confirm -b is set", cl.hasOption('b')); assertEquals("Confirm -b is set", "foo", cl.getOptionValue('b')); assertTrue("Confirm no extra args: " + cl.getArgList().size(), cl.getArgList().size() == 0); }
@Test public void testDoubleDash1() throws Exception { String[] args = new String[] { "--copt", "--", "-b", "toast" }; CommandLine cl = parser.parse(options, args); assertTrue("Confirm -c is set", cl.hasOption("c")); assertTrue("Confirm -b is not set", !cl.hasOption("b")); assertTrue("Confirm 2 extra args: " + cl.getArgList().size(), cl.getArgList().size() == 2); }
@Test public void testStopAtNonOptionLong() throws Exception { String[] args = new String[]{"--zop==1", "-abtoast", "--b=bar"}; CommandLine cl = parser.parse(options, args, true); assertFalse("Confirm -a is not set", cl.hasOption("a")); assertFalse("Confirm -b is not set", cl.hasOption("b")); assertTrue("Confirm 3 extra args: " + cl.getArgList().size(), cl.getArgList().size() == 3); }
@Test public void testSimpleShort() throws Exception { String[] args = new String[] { "-a", "-b", "toast", "foo", "bar" }; CommandLine cl = parser.parse(options, args); assertTrue("Confirm -a is set", cl.hasOption("a")); assertTrue("Confirm -b is set", cl.hasOption("b")); assertTrue("Confirm arg of -b", cl.getOptionValue("b").equals("toast")); assertTrue("Confirm size of extra args", cl.getArgList().size() == 2); }
@Test public void testBursting() throws Exception { String[] args = new String[] { "-acbtoast", "foo", "bar" }; CommandLine cl = parser.parse(options, args); assertTrue( "Confirm -a is set", cl.hasOption("a") ); assertTrue( "Confirm -b is set", cl.hasOption("b") ); assertTrue( "Confirm -c is set", cl.hasOption("c") ); assertTrue( "Confirm arg of -b", cl.getOptionValue("b").equals("toast") ); assertTrue( "Confirm size of extra args", cl.getArgList().size() == 2); }
@Test public void testSingleOption() throws Exception { String[] args = new String[] { "-r" }; CommandLine cl = parser.parse( _options, args); assertTrue( "Confirm -r is set", cl.hasOption("r") ); assertTrue( "Confirm -f is NOT set", !cl.hasOption("f") ); assertTrue( "Confirm -d is NOT set", !cl.hasOption("d") ); assertTrue( "Confirm -s is NOT set", !cl.hasOption("s") ); assertTrue( "Confirm -c is NOT set", !cl.hasOption("c") ); assertTrue( "Confirm no extra args", cl.getArgList().size() == 0); }
@Test public void testTwoValidOptions() throws Exception { String[] args = new String[] { "-r", "-f" }; CommandLine cl = parser.parse( _options, args); assertTrue( "Confirm -r is set", cl.hasOption("r") ); assertTrue( "Confirm -f is set", cl.hasOption("f") ); assertTrue( "Confirm -d is NOT set", !cl.hasOption("d") ); assertTrue( "Confirm -s is NOT set", !cl.hasOption("s") ); assertTrue( "Confirm -c is NOT set", !cl.hasOption("c") ); assertTrue( "Confirm no extra args", cl.getArgList().size() == 0); }
@Test public void testSingleLongOption() throws Exception { String[] args = new String[] { "--file" }; CommandLine cl = parser.parse( _options, args); assertTrue( "Confirm -r is NOT set", !cl.hasOption("r") ); assertTrue( "Confirm -f is set", cl.hasOption("f") ); assertTrue( "Confirm -d is NOT set", !cl.hasOption("d") ); assertTrue( "Confirm -s is NOT set", !cl.hasOption("s") ); assertTrue( "Confirm -c is NOT set", !cl.hasOption("c") ); assertTrue( "Confirm no extra args", cl.getArgList().size() == 0); }
@Test public void testSingleOptionFromGroup() throws Exception { String[] args = new String[] { "-f" }; CommandLine cl = parser.parse( _options, args); assertTrue( "Confirm -r is NOT set", !cl.hasOption("r") ); assertTrue( "Confirm -f is set", cl.hasOption("f") ); assertTrue( "Confirm -d is NOT set", !cl.hasOption("d") ); assertTrue( "Confirm -s is NOT set", !cl.hasOption("s") ); assertTrue( "Confirm -c is NOT set", !cl.hasOption("c") ); assertTrue( "Confirm no extra args", cl.getArgList().size() == 0); }
@Test public void testTwoOptionsFromDifferentGroup() throws Exception { String[] args = new String[] { "-f", "-s" }; CommandLine cl = parser.parse( _options, args); assertTrue( "Confirm -r is NOT set", !cl.hasOption("r") ); assertTrue( "Confirm -f is set", cl.hasOption("f") ); assertTrue( "Confirm -d is NOT set", !cl.hasOption("d") ); assertTrue( "Confirm -s is set", cl.hasOption("s") ); assertTrue( "Confirm -c is NOT set", !cl.hasOption("c") ); assertTrue( "Confirm NO extra args", cl.getArgList().size() == 0); }
@Test public void testTwoValidLongOptions() throws Exception { String[] args = new String[] { "--revision", "--file" }; CommandLine cl = parser.parse( _options, args); assertTrue( "Confirm -r is set", cl.hasOption("r") ); assertTrue( "Confirm -f is set", cl.hasOption("f") ); assertTrue( "Confirm -d is NOT set", !cl.hasOption("d") ); assertTrue( "Confirm -s is NOT set", !cl.hasOption("s") ); assertTrue( "Confirm -c is NOT set", !cl.hasOption("c") ); assertTrue( "Confirm no extra args", cl.getArgList().size() == 0); }
@Test public void testNoOptionsExtraArgs() throws Exception { String[] args = new String[] { "arg1", "arg2" }; CommandLine cl = parser.parse( _options, args); assertTrue( "Confirm -r is NOT set", !cl.hasOption("r") ); assertTrue( "Confirm -f is NOT set", !cl.hasOption("f") ); assertTrue( "Confirm -d is NOT set", !cl.hasOption("d") ); assertTrue( "Confirm -s is NOT set", !cl.hasOption("s") ); assertTrue( "Confirm -c is NOT set", !cl.hasOption("c") ); assertTrue( "Confirm TWO extra args", cl.getArgList().size() == 2); }