hedgewars/ArgParsers.pas
changeset 9988 317d46a2afd2
parent 9309 7e8f91634f80
child 9998 736015b847e3
equal deleted inserted replaced
9987:8f07b47a641b 9988:317d46a2afd2
    43     WriteLn(stdout, '        \/\\\       \/\\\  \///\\\              \/\\\           ');
    43     WriteLn(stdout, '        \/\\\       \/\\\  \///\\\              \/\\\           ');
    44     WriteLn(stdout, '         \/\\\\\\\\\\\\\/     \////\\\\\\\\\  /\\\\\\\\\\\      ');
    44     WriteLn(stdout, '         \/\\\\\\\\\\\\\/     \////\\\\\\\\\  /\\\\\\\\\\\      ');
    45     WriteLn(stdout, '          \/////////////          \/////////  \///////////      ');
    45     WriteLn(stdout, '          \/////////////          \/////////  \///////////      ');
    46     WriteLn(stdout, '                                                                ');
    46     WriteLn(stdout, '                                                                ');
    47     WriteLn(stdout, ' Command Line Parser Implementation by a Google Code-In Student ');
    47     WriteLn(stdout, ' Command Line Parser Implementation by a Google Code-In Student ');
    48     WriteLn(stdout, '             ASCII Art easter egg idea by @sheepluva            ');
       
    49     WriteLn(stdout, '                                                                ');
    48     WriteLn(stdout, '                                                                ');
    50 end;
    49 end;
    51 
    50 
    52 procedure DisplayUsage;
    51 procedure DisplayUsage;
    53 begin
    52 begin
   186 const videoArray: Array [1..5] of String = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth');
   185 const videoArray: Array [1..5] of String = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth');
   187       audioArray: Array [1..3] of String = ('--volume','--nomusic','--nosound');
   186       audioArray: Array [1..3] of String = ('--volume','--nomusic','--nosound');
   188       otherArray: Array [1..3] of String = ('--locale','--fullscreen','--showfps');
   187       otherArray: Array [1..3] of String = ('--locale','--fullscreen','--showfps');
   189       mediaArray: Array [1..10] of String = ('--fullscreen-width', '--fullscreen-height', '--width', '--height', '--depth', '--volume','--nomusic','--nosound','--locale','--fullscreen');
   188       mediaArray: Array [1..10] of String = ('--fullscreen-width', '--fullscreen-height', '--width', '--height', '--depth', '--volume','--nomusic','--nosound','--locale','--fullscreen');
   190       allArray: Array [1..18] of String = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth','--volume','--nomusic','--nosound','--locale','--fullscreen','--showfps','--altdmg','--frame-interval','--low-quality','--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags');
   189       allArray: Array [1..18] of String = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth','--volume','--nomusic','--nosound','--locale','--fullscreen','--showfps','--altdmg','--frame-interval','--low-quality','--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags');
   191       reallyAll: array[0..34] of shortstring = (
   190       reallyAll: array[0..35] of shortstring = (
   192                 '--prefix', '--user-prefix', '--locale', '--fullscreen-width', '--fullscreen-height', '--width',
   191                 '--prefix', '--user-prefix', '--locale', '--fullscreen-width', '--fullscreen-height', '--width',
   193                 '--height', '--frame-interval', '--volume','--nomusic', '--nosound',
   192                 '--height', '--frame-interval', '--volume','--nomusic', '--nosound',
   194                 '--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality', '--stereo', '--nick',
   193                 '--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality', '--stereo', '--nick',
   195   {deprecated}  '--depth', '--set-video', '--set-audio', '--set-other', '--set-multimedia', '--set-everything',
   194   {deprecated}  '--depth', '--set-video', '--set-audio', '--set-other', '--set-multimedia', '--set-everything',
   196   {internal}    '--internal', '--port', '--recorder', '--landpreview',
   195   {internal}    '--internal', '--port', '--recorder', '--landpreview',
   197   {misc}        '--stats-only', '--gci', '--help','--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags');
   196   {misc}        '--stats-only', '--gci', '--help','--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags','--lua-test');
   198 var cmdIndex: byte;
   197 var cmdIndex: byte;
   199 begin
   198 begin
   200     parseParameter:= false;
   199     parseParameter:= false;
   201     cmdIndex:= 0;
   200     cmdIndex:= 0;
   202 
   201 
   240         {--gci}                 29 : GciEasterEgg();
   239         {--gci}                 29 : GciEasterEgg();
   241         {--help}                30 : DisplayUsage();
   240         {--help}                30 : DisplayUsage();
   242         {--no-teamtag}          31 : cTagsMask := cTagsMask and not htTeamName;
   241         {--no-teamtag}          31 : cTagsMask := cTagsMask and not htTeamName;
   243         {--no-hogtag}           32 : cTagsMask := cTagsMask and not htName;
   242         {--no-hogtag}           32 : cTagsMask := cTagsMask and not htName;
   244         {--no-healthtag}        33 : cTagsMask := cTagsMask and not htHealth;
   243         {--no-healthtag}        33 : cTagsMask := cTagsMask and not htHealth;
   245         {--translucent-tags}    34 : cTagsMask := cTagsMask or htTransparent 
   244         {--translucent-tags}    34 : cTagsMask := cTagsMask or htTransparent;
       
   245         {--lua-test}            35 : begin cTestLua := true; cScriptName := getStringParameter(arg, paramIndex, parseParameter); WriteLn(stdout, 'Lua test file specified: ' + cScriptName);end;
   246     else
   246     else
   247         begin
   247         begin
   248         //Asusme the first "non parameter" is the replay file, anything else is invalid
   248         //Assume the first "non parameter" is the replay file, anything else is invalid
   249         if (recordFileName = '') and (Copy(cmd,1,2) <> '--') then
   249         if (recordFileName = '') and (Copy(cmd,1,2) <> '--') then
   250             recordFileName := cmd
   250             recordFileName := cmd
   251         else
   251         else
   252             begin
   252             begin
   253             WriteLn(stderr, '"'+cmd+'" is not a valid option');
   253             WriteLn(stderr, '"'+cmd+'" is not a valid option');
   349         begin
   349         begin
   350         WriteLn(stderr, '--internal should not be manually used');
   350         WriteLn(stderr, '--internal should not be manually used');
   351         GameType := gmtSyntax;
   351         GameType := gmtSyntax;
   352         end;
   352         end;
   353 
   353 
   354     if (not isInternal) and (recordFileName = '') then
   354     if (not cTestLua) and (not isInternal) and (recordFileName = '') then
   355         begin
   355         begin
   356         WriteLn(stderr, 'You must specify a replay file');
   356         WriteLn(stderr, 'You must specify a replay file');
   357         GameType := gmtSyntax;
   357         GameType := gmtSyntax;
   358         end
   358         end
   359     else if (recordFileName <> '') then
   359     else if (recordFileName <> '') then