Skip to content

Commit e6f9f16

Browse files
committed
Fixed Opening Files From Launch Args
1 parent 182d64d commit e6f9f16

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import the.bytecode.club.bytecodeviewer.bootloader.InstallFatJar;
3232
import the.bytecode.club.bytecodeviewer.bootloader.UpdateCheck;
3333
import the.bytecode.club.bytecodeviewer.cli.BCVCommandLine;
34+
import the.bytecode.club.bytecodeviewer.cli.CLICommand;
3435
import the.bytecode.club.bytecodeviewer.gui.MainViewerGUI;
3536
import the.bytecode.club.bytecodeviewer.gui.components.ExtendedJOptionPane;
3637
import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialog;
@@ -286,9 +287,28 @@ public static void boot()
286287
viewer.requestFocus();
287288

288289
//open files from launch args
289-
if (launchArgs.length >= 1)
290-
for (String s : launchArgs)
291-
openFiles(new File[]{new File(s)}, true);
290+
openFilesFromLaunchArguments();
291+
}
292+
293+
private static void openFilesFromLaunchArguments()
294+
{
295+
if(launchArgs.length < 1)
296+
return;
297+
298+
//parse input for commands
299+
for (int i = 0; i < launchArgs.length; i++)
300+
{
301+
String fileInput = launchArgs[i];
302+
CLICommand command = CLI.getCommand(fileInput);
303+
304+
if (command != null)
305+
{
306+
if(command.hasArgs)
307+
i++;
308+
}
309+
else
310+
openFiles(new File[]{new File(fileInput)}, true);
311+
}
292312
}
293313

294314
/**

0 commit comments

Comments
 (0)