added package name in parser
This commit is contained in:
parent
67e7655ce9
commit
945571adf0
@ -11,6 +11,7 @@ public class ArgParse {
|
|||||||
|
|
||||||
/* distribution the user want */
|
/* distribution the user want */
|
||||||
private static String distribution;
|
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
|
* 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);
|
jCommander.parse(args);
|
||||||
// store the argument parsed in the variable
|
// store the argument parsed in the variable
|
||||||
distribution = params.distribution;
|
distribution = params.distribution;
|
||||||
|
packet = params.packet;
|
||||||
|
|
||||||
} 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 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);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -44,4 +47,13 @@ public class ArgParse {
|
|||||||
public static String getDistribution() {
|
public static String getDistribution() {
|
||||||
return distribution;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,4 +23,12 @@ public class CommandLineParams {
|
|||||||
description = "Linux distribution to search in",
|
description = "Linux distribution to search in",
|
||||||
required = false)
|
required = false)
|
||||||
public String distribution;
|
public String distribution;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Packet the user want to search
|
||||||
|
*/
|
||||||
|
@Parameter(names = {"--packet", "-p"},
|
||||||
|
description = "Packet to search",
|
||||||
|
required = true)
|
||||||
|
public String packet;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,5 +6,6 @@ public class Main {
|
|||||||
// 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.getDistribution());
|
||||||
|
System.out.println(ArgParse.getPacket());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user