Skip to content

Commit

Permalink
version output
Browse files Browse the repository at this point in the history
  • Loading branch information
lmajano committed Apr 10, 2024
1 parent 13a684e commit cbc2a3a
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/main/java/ortus/boxlang/runtime/BoxRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,22 @@ public static void main( String[] args ) {
// Get a runtime going
BoxRuntime boxRuntime = BoxRuntime.getInstance( options.debug(), options.configFile(), options.runtimeHome() );

// Output Options
if ( options.debugger() ) {
// Show version
if ( Boolean.TRUE.equals( options.showVersion() ) ) {
System.out.println( "Ortus BoxLang v" + boxRuntime.VERSION );
System.out.println( "Copyright Ortus Solutions, Corp" );
System.out.println( "https://boxlang.io" );
System.out.println( "https://ortussolutions.com" );
}
// Debugger
else if ( options.debugger() ) {
IBoxLangDebugger debugger;

debugger = new BoxLangRemoteDebugger( 4404 );

try {
debugger.startDebugSession();
} catch ( Exception e ) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return;
Expand Down Expand Up @@ -179,7 +185,8 @@ private static CLIOptions parseEnvironmentVariables( CLIOptions options ) {
printAST,
transpile,
debugger,
runtimeHome
runtimeHome,
options.showVersion()
);
}

Expand All @@ -203,11 +210,18 @@ private static CLIOptions parseCommandLineOptions( String[] args ) {
String code = null;
Boolean transpile = false;
Boolean debugger = false;
Boolean showVersion = false;

// Consume args in order via the `current` variable
while ( !argsList.isEmpty() ) {
current = argsList.remove( 0 );

// ShowVersion mode Flag, we find and continue to the next argument
if ( current.equalsIgnoreCase( "--version" ) ) {
showVersion = true;
continue;
}

// Debug mode Flag, we find and continue to the next argument
if ( current.equalsIgnoreCase( "--debug" ) ) {
debug = true;
Expand Down Expand Up @@ -269,7 +283,7 @@ private static CLIOptions parseCommandLineOptions( String[] args ) {
file = templatePath.toString();
}

return new CLIOptions( file, debug, code, configFile, printAST, transpile, debugger, runtimeHome );
return new CLIOptions( file, debug, code, configFile, printAST, transpile, debugger, runtimeHome, showVersion );
}

/**
Expand All @@ -283,6 +297,7 @@ private static CLIOptions parseCommandLineOptions( String[] args ) {
* @param transpile Whether or not to transpile the source code to Java
* @param debugger Whether or not to start the debugger
* @param runtimeHome The path to the runtime home
* @param showVersion Whether or not to show the version of the runtime
*/
public record CLIOptions(
String templatePath,
Expand All @@ -292,7 +307,8 @@ public record CLIOptions(
Boolean printAST,
Boolean transpile,
Boolean debugger,
String runtimeHome ) {
String runtimeHome,
Boolean showVersion ) {
// The record automatically generates the constructor, getters, equals, hashCode, and toString methods.
}

Expand Down

0 comments on commit cbc2a3a

Please sign in to comment.