diff --git a/src/main/java/fr/packageviewer/ArgParse.java b/src/main/java/fr/packageviewer/ArgParse.java index b037ad1..8650a87 100644 --- a/src/main/java/fr/packageviewer/ArgParse.java +++ b/src/main/java/fr/packageviewer/ArgParse.java @@ -11,6 +11,7 @@ public class ArgParse { /* distribution the user want */ private static String distribution; + private static String packet; /** * Get the command line argument given by the user, parse it with the parser and store it in the corresponding variable @@ -29,9 +30,11 @@ public class ArgParse { jCommander.parse(args); // store the argument parsed in the variable distribution = params.distribution; + packet = params.packet; + } catch (Exception e) { // if the parsing failed, print the error message and exit the program - System.out.println("You forgot the distribution name."); + 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.exit(0); } } @@ -44,4 +47,13 @@ public class ArgParse { public static String getDistribution() { return distribution; } + + /** + * Get the packet name, this one isn't optional + * @author Capelier-Marla + * @return String: the packet name + */ + public static String getPacket() { + return packet; + } } diff --git a/src/main/java/fr/packageviewer/CommandLineParams.java b/src/main/java/fr/packageviewer/CommandLineParams.java index 25418b3..be87210 100644 --- a/src/main/java/fr/packageviewer/CommandLineParams.java +++ b/src/main/java/fr/packageviewer/CommandLineParams.java @@ -23,4 +23,12 @@ public class CommandLineParams { description = "Linux distribution to search in", required = false) public String distribution; + + /** + * Packet the user want to search + */ + @Parameter(names = {"--packet", "-p"}, + description = "Packet to search", + required = true) + public String packet; } diff --git a/src/main/java/fr/packageviewer/Main.java b/src/main/java/fr/packageviewer/Main.java index b74f7d2..82d35a2 100644 --- a/src/main/java/fr/packageviewer/Main.java +++ b/src/main/java/fr/packageviewer/Main.java @@ -6,5 +6,6 @@ public class Main { // send the command line arguments to the parser ArgParse.parseArguments(args); System.out.println(ArgParse.getDistribution()); + System.out.println(ArgParse.getPacket()); } }