hedgewars/ArgParsers.pas
changeset 13487 d23731fe84d4
parent 11789 e2de320aaf69
child 13506 36f3f77e9b1b
equal deleted inserted replaced
13486:4ef83bcb850b 13487:d23731fe84d4
    32 {$ENDIF}
    32 {$ENDIF}
    33 
    33 
    34 implementation
    34 implementation
    35 uses uVariables, uTypes, uUtils, uSound, uConsts;
    35 uses uVariables, uTypes, uUtils, uSound, uConsts;
    36 var isInternal: Boolean;
    36 var isInternal: Boolean;
       
    37     helpCommandUsed: Boolean;
    37 
    38 
    38 {$IFDEF HWLIBRARY}
    39 {$IFDEF HWLIBRARY}
    39 
    40 
    40 type PCharArray = array[0..255] of PChar;
    41 type PCharArray = array[0..255] of PChar;
    41      PPCharArray = ^PCharArray;
    42      PPCharArray = ^PCharArray;
    99     WriteLn(stdout, ' --stats-only');
   100     WriteLn(stdout, ' --stats-only');
   100     WriteLn(stdout, ' --help');
   101     WriteLn(stdout, ' --help');
   101     WriteLn(stdout, '');
   102     WriteLn(stdout, '');
   102     WriteLn(stdout, 'For more detailed help and examples go to:');
   103     WriteLn(stdout, 'For more detailed help and examples go to:');
   103     WriteLn(stdout, 'http://hedgewars.org/kb/CommandLineOptions');
   104     WriteLn(stdout, 'http://hedgewars.org/kb/CommandLineOptions');
   104     GameType:= gmtSyntax;
   105     GameType:= gmtSyntaxHelp;
       
   106     helpCommandUsed:= true;
   105 end;
   107 end;
   106 
   108 
   107 procedure setDepth(var paramIndex: LongInt);
   109 procedure setDepth(var paramIndex: LongInt);
   108 begin
   110 begin
   109     WriteLn(stdout, 'WARNING: --depth is a deprecated command, which could be removed in a future version!');
   111     WriteLn(stdout, 'WARNING: --depth is a deprecated command, which could be removed in a future version!');
   355         else nextIndex:= index+1;
   357         else nextIndex:= index+1;
   356         wrongParameter:= parseParameter( ParamStr(index), ParamStr(nextIndex), paramIndex);
   358         wrongParameter:= parseParameter( ParamStr(index), ParamStr(nextIndex), paramIndex);
   357         inc(paramIndex);
   359         inc(paramIndex);
   358         end;
   360         end;
   359     if wrongParameter = true then
   361     if wrongParameter = true then
   360         GameType:= gmtSyntax;
   362         GameType:= gmtBadSyntax;
   361 end;
   363 end;
   362 
   364 
   363 procedure GetParams;
   365 procedure GetParams;
   364 begin
   366 begin
   365     isInternal:= (ParamStr(1) = '--internal');
   367     isInternal:= (ParamStr(1) = '--internal');
       
   368     helpCommandUsed:= false;
   366 
   369 
   367     UserPathPrefix := _S'.';
   370     UserPathPrefix := _S'.';
   368     PathPrefix     := cDefaultPathPrefix;
   371     PathPrefix     := cDefaultPathPrefix;
   369     recordFileName := '';
   372     recordFileName := '';
   370     parseCommandLine();
   373     parseCommandLine();
   371 
   374 
   372     if (isInternal) and (ParamCount<=1) then
   375     if (isInternal) and (ParamCount<=1) then
   373         begin
   376         begin
   374         WriteLn(stderr, '--internal should not be manually used');
   377         WriteLn(stderr, '--internal should not be manually used');
   375         GameType := gmtSyntax;
   378         GameType := gmtBadSyntax;
   376         end;
   379         end;
   377 
   380 
   378     if (not cTestLua) and (not isInternal) and (recordFileName = '') then
   381     if (not helpCommandUsed) then
   379         begin
   382         if (not cTestLua) and (not isInternal) and (recordFileName = '') then
   380         WriteLn(stderr, 'You must specify a replay file');
   383             begin
   381         GameType := gmtSyntax;
   384             WriteLn(stderr, 'You must specify a replay file');
   382         end
   385             GameType := gmtBadSyntax;
   383     else if (recordFileName <> '') then
   386             end
   384         WriteLn(stdout, 'Attempting to play demo file "' + recordFilename + '"');
   387         else if (recordFileName <> '') then
   385 
   388             WriteLn(stdout, 'Attempting to play demo file "' + recordFilename + '"');
   386     if (GameType = gmtSyntax) then
   389 
       
   390     if (GameType = gmtBadSyntax) then
   387         WriteLn(stderr, 'Please use --help to see possible arguments and their usage');
   391         WriteLn(stderr, 'Please use --help to see possible arguments and their usage');
   388 
   392 
   389     (*
   393     (*
   390     WriteLn(stdout,'PathPrefix:     ' + PathPrefix);
   394     WriteLn(stdout,'PathPrefix:     ' + PathPrefix);
   391     WriteLn(stdout,'UserPathPrefix: ' + UserPathPrefix);
   395     WriteLn(stdout,'UserPathPrefix: ' + UserPathPrefix);