Skip to content

Commit

Permalink
JGrabClient show JGrab Daemon version information.
Browse files Browse the repository at this point in the history
  • Loading branch information
renato committed May 16, 2017
1 parent 5ce649e commit 5144c37
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions jgrab-client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ fn main() {
}
"--version" | "-v" => {
println!("JGrab Client Version: {}", VERSION);
show_daemon_version();
return
}
"-e" => usage_error(&format!("-e option missing code snippet")),
Expand Down Expand Up @@ -257,6 +258,12 @@ fn check_status(child: &mut Child) {
}
}

fn show_daemon_version() {
if let Some(_) = send_message(&mut TextInput(Cursor::new("--version".to_string())), false) {
println!("(Run the JGrab daemon to see its version)");
}
}

fn log(message: &str) {
println!("=== JGrab Client - {} ===", message)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class JGrabDaemon {

private static final Logger logger = LoggerFactory.getLogger( JGrabDaemon.class );
private static final String STOP_OPTION = "--stop";
private static final String VERSION_OPTION = "--version";

private static final PersistentCache libsCache = new PersistentCache();

Expand Down Expand Up @@ -93,6 +94,14 @@ public static void start( RunArgs runArgs ) {
return;
}

if ( input.equals( VERSION_OPTION ) ) {
logger.info( "--version option received" );
System.setOut( out );
System.setErr( out );
JGrabRunner.version();
continue;
}

if ( input.startsWith( JGrabRunner.SNIPPET_OPTION ) ) {
String snippet = input.substring( JGrabRunner.SNIPPET_OPTION.length() );
if ( snippet.isEmpty() ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private static JGrabOptions error( String reason ) {
throw new JGrabError( reason + "\n\nUsage: jgrab (-e <java_source>) | java_file" );
}

private static JGrabOptions version() {
public static JGrabOptions version() {
URL jarUrl = JGrabRunner.class.getProtectionDomain().getCodeSource().getLocation();
String version = "UNKNOWN";

Expand Down

0 comments on commit 5144c37

Please sign in to comment.