mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-28 12:02:15 -05:00
Fix command line args
This commit is contained in:
parent
85f608d515
commit
469d9d02e5
@ -1418,21 +1418,33 @@ var
|
|||||||
ErrorMsg : string;
|
ErrorMsg : string;
|
||||||
begin
|
begin
|
||||||
DoRun := false;
|
DoRun := false;
|
||||||
if Paramcount = 1 then
|
// paramcount = 1 means we got only one parameter. We assume this to be a file.
|
||||||
|
// and try to open it accordingly
|
||||||
|
if (Paramcount = 1) and not (Application.HasOption('open')) then
|
||||||
begin
|
begin
|
||||||
|
writeln('Opening file: ' + ParamStr(1));
|
||||||
if FileExists(ParamStr(1)) then
|
if FileExists(ParamStr(1)) then
|
||||||
|
begin
|
||||||
LoadScriptFile(paramstr(1));
|
LoadScriptFile(paramstr(1));
|
||||||
|
end;
|
||||||
end else
|
end else
|
||||||
begin;
|
// we have more parameters. Check for specific options. (-r -o, --run --open)
|
||||||
ErrorMsg:=Application.CheckOptions('ro:','run open:');
|
begin
|
||||||
|
ErrorMsg:=Application.CheckOptions('ro:',['run', 'open:']);
|
||||||
if ErrorMsg <> '' then
|
if ErrorMsg <> '' then
|
||||||
mDebugLn(ErrorMSG)
|
begin
|
||||||
else
|
mDebugLn('ERROR IN COMMAND LINE ARGS: ' + ErrorMSG)
|
||||||
|
end else
|
||||||
begin
|
begin
|
||||||
if Application.HasOption('o','open') then
|
if Application.HasOption('o','open') then
|
||||||
begin;
|
begin
|
||||||
|
writeln('Opening file: ' + Application.GetOptionValue('o','open'));
|
||||||
LoadScriptFile(Application.GetOptionValue('o','open'));
|
LoadScriptFile(Application.GetOptionValue('o','open'));
|
||||||
DoRun:= Application.HasOption('r','run');
|
DoRun:= Application.HasOption('r','run');
|
||||||
|
end else
|
||||||
|
// no valid options
|
||||||
|
begin
|
||||||
|
writeln('No valid command line args are passed');
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user