Commit d5c3d75d by Tobias

update cli logic

1 parent 0cd2be20
......@@ -23,9 +23,18 @@ public class Cli
private ImageFormat image;
private StegosuitePresenter presenter;
private String getSteganogramPath(CommandLine cmd) {
if (cmd.getArgs().length > 0) {
return cmd.getArgs()[0];
} else {
return null;
}
}
public void embed(CommandLine cmd) {
String steganogramPath = cmd.getOptionValue("e");
String steganogramPath = getSteganogramPath(cmd);
if (steganogramPath == null)
return;
if (!validImageFormat(steganogramPath))
return;
......@@ -49,10 +58,12 @@ public class Cli
}
public void extract(CommandLine cmd) {
String steganogramPath = cmd.getOptionValue("x");
String steganogramPath = getSteganogramPath(cmd);
if (steganogramPath == null)
return;
if (!validImageFormat(steganogramPath))
return;
pointFilter(cmd);
String key = cmd.getOptionValue("k");
extract(key);
......@@ -63,7 +74,9 @@ public class Cli
}
public void capacity(CommandLine cmd) {
String steganogramPath = cmd.getOptionValue("c");
String steganogramPath = getSteganogramPath(cmd);
if (steganogramPath == null)
return;
if (!validImageFormat(steganogramPath))
return;
pointFilter(cmd);
......
......@@ -19,14 +19,14 @@ public class CliParser {
Options options = new Options();
options.addOption("v", "verbose", false, "show more information");
options.addOption("e", "embed", true, "embed data into image");
options.addOption("x", "extract", true, "extract data from image");
options.addOption("e", "embed", false, "embed data into image");
options.addOption("x", "extract", false, "extract data from image");
options.addOption("m", "message", true, "message to embed");
options.addOption("k", "key", true, "secret key used for encrytion and hiding");
options.addOption("c", "capacity", true, "shows the maximum amount of data which can be embededded");
options.addOption("c", "capacity", false, "shows the maximum amount of data which can be embededded");
options.addOption("h", "help", false, "displays this help message");
Option files = Option.builder("f").hasArgs().longOpt("file").desc("files to embed").build();
Option files = Option.builder("f").hasArgs().longOpt("files").desc("files to embed").build();
options.addOption(files);
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!