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