we don't need --name anymore to pick the package name
This commit is contained in:
parent
945571adf0
commit
1fa25c47f5
@ -28,13 +28,20 @@ public class ArgParse {
|
||||
try {
|
||||
// parse the argument from list of String
|
||||
jCommander.parse(args);
|
||||
// store the argument parsed in the variable
|
||||
distribution = params.distribution;
|
||||
packet = params.packet;
|
||||
if(params.help) {
|
||||
jCommander.setProgramName("PackageViewer");
|
||||
jCommander.usage();
|
||||
} else {
|
||||
// store the argument parsed in the variable
|
||||
packet = params.packet;
|
||||
distribution = params.distribution;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// if the parsing failed, print the error message and exit the program
|
||||
System.out.println("You forgot something, please enter the package name and the distribution name if you want to search in a specific one");
|
||||
jCommander.setProgramName("PackageViewer");
|
||||
jCommander.usage();
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
package fr.packageviewer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.beust.jcommander.Parameter;
|
||||
|
||||
/**
|
||||
@ -10,11 +7,13 @@ import com.beust.jcommander.Parameter;
|
||||
* @author Capelier-Marla
|
||||
*/
|
||||
public class CommandLineParams {
|
||||
|
||||
/**
|
||||
* List of parameters given by the user
|
||||
* Packet the user want to search, only parameter without names
|
||||
*/
|
||||
@Parameter
|
||||
public List<String> parameters = new ArrayList<>();
|
||||
@Parameter(description = "Packet to search",
|
||||
required = true)
|
||||
public String packet;
|
||||
|
||||
/**
|
||||
* Distribution the user want to search packages in
|
||||
@ -25,10 +24,10 @@ public class CommandLineParams {
|
||||
public String distribution;
|
||||
|
||||
/**
|
||||
* Packet the user want to search
|
||||
* Displays the help
|
||||
*/
|
||||
@Parameter(names = {"--packet", "-p"},
|
||||
description = "Packet to search",
|
||||
required = true)
|
||||
public String packet;
|
||||
@Parameter(names = {"--help", "-h"},
|
||||
help = true,
|
||||
required = false)
|
||||
public boolean help = false;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ public class Main {
|
||||
public static void main(String[] args) {
|
||||
// send the command line arguments to the parser
|
||||
ArgParse.parseArguments(args);
|
||||
System.out.println(ArgParse.getDistribution());
|
||||
System.out.println(ArgParse.getPacket());
|
||||
System.out.println(ArgParse.getDistribution());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user