Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dependencies {
compile group: 'com.itextpdf', name: 'itextpdf', version: '5.5.11'
compile group: 'com.jcraft', name: 'jsch', version: '0.1.54'
compile group: 'org.jfree', name: 'jfreechart', version: '1.5.0'
compile group: 'com.beust', name: 'jcommander', version: '1.72'
testCompile 'junit:junit:4.12'
}

Expand Down
40 changes: 40 additions & 0 deletions src/main/java/net/atomique/ksar/CommandLineArgs.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2017 The kSAR Project. All rights reserved.
* See the LICENSE file in the project root for more information.
*/

package net.atomique.ksar;

import com.beust.jcommander.Parameter;

public class CommandLineArgs {

@Parameter(names = "-input", description = "sar file to be processed")
private String filename;

@Parameter(names = "-help", description = "show usage", help = true)
private boolean help;

@Parameter(names = "-version", description = "print version information")
private boolean version = false;

@Parameter(names = "-test", description = "debug mode")
private boolean debug = false;

public String getFilename() {
return filename;
}

public boolean isHelp() {
return help;
}

public boolean isVersion() {
return version;
}

public boolean isDebug() {
return debug;
}

}
58 changes: 31 additions & 27 deletions src/main/java/net/atomique/ksar/Main.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/*
* Copyright 2008 The kSAR Project. All rights reserved.
* Copyright 2017 The kSAR Project. All rights reserved.
* See the LICENSE file in the project root for more information.
*/

package net.atomique.ksar;

import com.beust.jcommander.JCommander;
import net.atomique.ksar.ui.Desktop;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -15,6 +16,7 @@
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;


public class Main {

private static final Logger log = LoggerFactory.getLogger(Main.class);
Expand Down Expand Up @@ -61,8 +63,6 @@ public void run() {
}

public static void main(String[] args) {
int i = 0;
String arg;

log.trace("main - Start");
log.trace("ksar Version : {}", VersionNumber.getVersionNumber());
Expand All @@ -79,32 +79,36 @@ public static void main(String[] args) {
globaloptions = GlobalOptions.getInstance();


if (args.length > 0) {
while (i < args.length && args[i].startsWith("-")) {
arg = args[i++];
if ("-version".equals(arg)) {
show_version();
System.exit(0);
}
if ("-help".equals(arg)) {
usage();
continue;
}
if ("-test".equals(arg)) {
GlobalOptions.setDodebug(true);
continue;
}
if ("-input".equals(arg)) {
if (i < args.length) {
GlobalOptions.setCLfilename(args[i++]);
} else {
exit_error(resource.getString("INPUT_REQUIRE_ARG"));
}
continue;
}
}
//Cmdline_parsing
CommandLineArgs cmdl_args = new CommandLineArgs();
JCommander .newBuilder()
.addObject(cmdl_args)
.build()
.parse(args);

if (cmdl_args.isVersion()) {
show_version();
System.exit(0);
}

if (cmdl_args.isHelp()) {
usage();
System.exit(0);
}

if (cmdl_args.isDebug()) {
GlobalOptions.setDodebug(true);
} else {
GlobalOptions.setDodebug(false);
}

if (cmdl_args.getFilename() != null) {
if (cmdl_args.getFilename().isEmpty()) {
exit_error(resource.getString("INPUT_REQUIRE_ARG"));
} else {
GlobalOptions.setCLfilename(cmdl_args.getFilename());
}
}
make_ui();

}
Expand Down