Questions tagged [args4j]

arg4j makes it easy to parse command line options/arguments in your CUI application.

args4j is a small open-source class library that makes it easy to parse command line options/arguments in applications.

Features:

  • It makes command line parsing very easy by using
  • Generate usage text very easily
  • Generate HTML/XML documentation listing all options
  • Full localization support
  • Designed to parse like options, as opposed to GNU-style (where ls -lR is considered to have two options l and R)
  • Licensed under the

Try a small sample application today.

18 questions
8
votes
1 answer

How to split string to arguments like shell?

Here is a list of argument parser, but they accept string array. Now, I got a string like -s -d "String with space" -d "string with \" escape \n the next line" I want to split the string to -s -d String with space -d string with " escape the next…
wener
  • 7,191
  • 6
  • 54
  • 78
8
votes
1 answer

Multiple args with arg4j

I have a parameter which I need to parse from command line. I use for this arg4j of version 2.0.23. I need to parse path parameter and in command line can be specified one or more path's. So I need to parse multiple params. Here's the way I…
user2281439
  • 673
  • 2
  • 11
  • 19
4
votes
2 answers

args4j: How to make an argument required if another argument is/isn't given?

@Options(name="--in-file") String fileName; @Option(name="--table") String table; I would like to make the --table option be required if and only if no value is given for --in-file. How might I go about doing this? I know that there are some…
Matthew Herbst
  • 29,477
  • 23
  • 85
  • 128
4
votes
2 answers

How to add command line parameter dependency using JCommander?

I am using JCommander for command line parameters parsing. I would like to add parameter dependency, but from the JCommander documentation, I am not able to find out if it is even supported. Has anyone tried it ? For example, java -jar Some.jar -a…
Arjun Patel
  • 345
  • 6
  • 22
3
votes
0 answers

How to handle both args4j options and Java opts?

I am using args4j in order to process my options that I will pass as parameter to the program. I also want to increase the heap size. So that I would like to run something like: > hadoop jar hadoop-program.jar -i /input/directory -o…
dbustosp
  • 4,208
  • 25
  • 46
3
votes
2 answers

Giving an @Option annotation a default setting, java

@Option(name = "-readFromFolder",usage = "specifies a folder containing files to read") private String folderName; The way it works now is that the user has specifies the folder -readFromFolder=/home I want them to be able to say…
clueless user
  • 1,301
  • 2
  • 11
  • 12
3
votes
2 answers

Args4j list arguments that contain space not handled

I am dealing with a strange args4j bug. I am handling list command line arguments aaa.jar -list special_date=2015-05-05 "special_name=bob the builder" This is handled with StringArrayOptionHandler . And when I retreive the arguments of the list…
George Kouzmov
  • 319
  • 4
  • 15
2
votes
1 answer

How to parse argument with args4j in kotlin?

I need to parse info from command line, so I choose args4j library. Format of command line: ls [-l] [-h] [-r] [-o output.file] directory_or_file. I've tried to create options and then parse. When I get only "-ls", output is correct, but when I get…
Marlock
  • 275
  • 2
  • 9
2
votes
0 answers

Space in String argument is not parsed by args4j

I'm trying to pass a text/String parameter to my java tool from Jenkins which is a String containing all sorts of characters. When the args4j option parses the flag then it only considers the first word and as soon as it hits the second word(after…
Rishabh Agarwal
  • 91
  • 1
  • 1
  • 7
0
votes
1 answer

How do I re-use repeated arguments in arg4j over multiple classes?

I have some data that is repeated between multiple commands. How can I deduplicate the common parameters with a class? If I can use a class, I will be able to deduplicate other code as well. Sample code provided below where common1 and common2 are…
joseph
  • 2,429
  • 1
  • 22
  • 43
0
votes
1 answer

Interoperation between Java library Args4j and Scala 2.10

I'd like to use the args4j Java library in my Scala v2.10 application. However, I am running into some trouble. As an example, I have a class to store my arguments in Java as follows. public class MyArgs { @Option(name = "-i", usage = "file input",…
Jane Wayne
  • 8,205
  • 17
  • 75
  • 120
0
votes
1 answer

Args4j: Is it possible to required one and only option through two (or more) options?

Imagine I have this two options in args4j: @Option(name = "-a") boolean a; @Option(name = "-b") boolean b; Is it possible, with annotation, to say that i want exactly either a or b (and only one of them) Thanks!
Jitsumi
  • 127
  • 2
  • 9
0
votes
2 answers

How can I validate options with args4j?

With following code, @Option(name = "age") // min = "1" private int age; How can I validate age field? Say must be bigger than zero?
Jin Kwon
  • 20,295
  • 14
  • 115
  • 184
0
votes
2 answers

Remove default value in printUsage() method. [args4j library]

How to get rid of "(default:value)" when using printUsage() method? Image I tried to look at the source code of args4j library and searched for printUsage() method in CmdLineParser Class but didn't find anything there. (link) The problem appears…
CroModder
  • 27
  • 7
0
votes
1 answer

How do I access main context in sub-commands using args4j to implement sub-command handler?

I just discovered args4j, soooo nice to use coming from commons-cli! I am implementing a sub-command handler where each of the sub-commands will need to access a session object obtained through logging on using credentials common to all…
AndyJ
  • 1,204
  • 3
  • 14
  • 28
1
2