/** Add an argument to those to be accepted on the command line. * Argument order reflects ArgDecl. * @param hasValue True if the command takes a (string) value * @param argName Name * @return The CommandLine processor object */ public CmdLineArgs add(boolean hasValue, String argName) { return add(new ArgDecl(hasValue, argName)) ; }
/** Add an argument to those to be accepted on the command line. * @param argName Name * @param hasValue True if the command takes a (string) value * @return The CommandLine processor object */ public CmdLineArgs add(String argName, boolean hasValue) { return add(new ArgDecl(hasValue, argName)) ; }
/** Add an argument to those to be accepted on the command line. * Argument order reflects ArgDecl. * @param hasValue True if the command takes a (string) value * @param argName Name * @return The CommandLine processor object */ public CmdLineArgs add(boolean hasValue, String argName) { return add(new ArgDecl(hasValue, argName)) ; }
/** Add an argument to those to be accepted on the command line. * @param argName Name * @param hasValue True if the command takes a (string) value * @return The CommandLine processor object */ public CmdLineArgs add(String argName, boolean hasValue) { return add(new ArgDecl(hasValue, argName)) ; }
@Test public void test_nArg1() { String args[] = new String[]{ "-arg=V1", "--arg=V2", "-v"} ; CmdLineArgs cl = new CmdLineArgs(args) ; ArgDecl argA = new ArgDecl(true, "-arg") ; cl.add(argA) ; ArgDecl argV = new ArgDecl(false, "-v") ; cl.add(argV) ; cl.process() ; assertTrue("No -arg= argument found" , cl.contains(argA) ) ; Iterator<String> iter = cl.getValues("arg").iterator() ; assertEquals("Argument 1", iter.next() , "V1") ; assertEquals("Argument 2", iter.next() , "V2") ; } }
@Test public void test_nArg1() { String args[] = new String[]{ "-arg=V1", "--arg=V2", "-v"} ; CmdLineArgs cl = new CmdLineArgs(args) ; ArgDecl argA = new ArgDecl(true, "-arg") ; cl.add(argA) ; ArgDecl argV = new ArgDecl(false, "-v") ; cl.add(argV) ; cl.process() ; assertTrue("No -arg= argument found" , cl.contains(argA) ) ; Iterator<String> iter = cl.getValues("arg").iterator() ; assertEquals("Argument 1", iter.next() , "V1") ; assertEquals("Argument 2", iter.next() , "V2") ; } }
@Test public void test_Flag3() { String args[] = new String[]{ "-a", "filename"} ; CmdLineArgs cl = new CmdLineArgs(args) ; ArgDecl argA = new ArgDecl(false, "-a") ; cl.add(argA) ; cl.process() ; assertTrue("No -a argument found" , cl.contains(argA) ) ; }
@Test public void test_Flag2() { String args[] = new String[]{ "-a"} ; CmdLineArgs cl = new CmdLineArgs(args) ; ArgDecl argA = new ArgDecl(false, "-a") ; cl.add(argA) ; cl.process() ; assertTrue("No -a argument found" , cl.contains(argA) ) ; }
@Test public void test_Flag3() { String args[] = new String[]{ "-a", "filename"} ; CmdLineArgs cl = new CmdLineArgs(args) ; ArgDecl argA = new ArgDecl(false, "-a") ; cl.add(argA) ; cl.process() ; assertTrue("No -a argument found" , cl.contains(argA) ) ; }
@Test public void test_Flag1() { String args[] = new String[]{ ""} ; CmdLineArgs cl = new CmdLineArgs(args) ; ArgDecl argA = new ArgDecl(false, "-a") ; cl.add(argA) ; cl.process() ; assertTrue("-a argument found" , ! cl.contains(argA) ) ; }
@Test public void test_Arg1() { String args[] = new String[]{ ""} ; CmdLineArgs cl = new CmdLineArgs(args) ; ArgDecl argA = new ArgDecl(true, "-arg") ; cl.add(argA) ; cl.process() ; assertTrue("-arg argument found" , ! cl.contains(argA) ) ; }
@Test public void test_Flag1() { String args[] = new String[]{ ""} ; CmdLineArgs cl = new CmdLineArgs(args) ; ArgDecl argA = new ArgDecl(false, "-a") ; cl.add(argA) ; cl.process() ; assertTrue("-a argument found" , ! cl.contains(argA) ) ; }
@Test public void test_Arg1() { String args[] = new String[]{ ""} ; CmdLineArgs cl = new CmdLineArgs(args) ; ArgDecl argA = new ArgDecl(true, "-arg") ; cl.add(argA) ; cl.process() ; assertTrue("-arg argument found" , ! cl.contains(argA) ) ; }
@Test public void test_Flag2() { String args[] = new String[]{ "-a"} ; CmdLineArgs cl = new CmdLineArgs(args) ; ArgDecl argA = new ArgDecl(false, "-a") ; cl.add(argA) ; cl.process() ; assertTrue("No -a argument found" , cl.contains(argA) ) ; }
@Test public void test_Arg2() { String args[] = new String[]{ "-arg=ARG", "filename"} ; CmdLineArgs cl = new CmdLineArgs(args) ; ArgDecl argA = new ArgDecl(true, "arg") ; cl.add(argA) ; cl.process() ; assertTrue("No -arg= argument found" , cl.contains(argA) ) ; assertEquals("", cl.getValue(argA) , "ARG") ; assertEquals("", cl.getArg("arg").getValue() , "ARG") ; }
@Test public void test_Arg2() { String args[] = new String[]{ "-arg=ARG", "filename"} ; CmdLineArgs cl = new CmdLineArgs(args) ; ArgDecl argA = new ArgDecl(true, "arg") ; cl.add(argA) ; cl.process() ; assertTrue("No -arg= argument found" , cl.contains(argA) ) ; assertEquals("", cl.getValue(argA) , "ARG") ; assertEquals("", cl.getArg("arg").getValue() , "ARG") ; }