[tip] Test command line settings with EchoArgs 9.78 PRO

Occasionally, applications will allow you to call external helper programs via command line. That can get tricky when you're supplying a command line template and the application does some token replacement before running the commandline. For example, when I hooked up SourceGear Vault to WinMerge, the trick was in figuring out which tokens it was replacing and how those mapped to WinMerge's commandline arguments. So if my commandline setting is /dl "%WORKING_LABEL%" /dr "%OTHER_LABEL%" "%WORKING_PATH%" "%OTHER_PATH%" "%DEST_PATH%", what exactly is being passed for "WORKING_LABEL" and "OTHER_LABEL"?

Thus, I proudly release EchoArgs 9.78 PRO, the following (ahem) DOS Batch File:

TITLE EchoArgs 9.78 PRO
@echo off
echo Command Line: %*
echo Path :        %~dp0
echo .
echo Arguments 
echo 0: %0
echo 1: %1
echo 2: %2 
echo 3: %3
echo 4: %4
echo 5: %5
echo 6: %6
echo 7: %7
echo 8: %8
echo 9: %9
pause

Here's what it does:

C:\>echoargs test "inscrutable monkey" 5 geronimo

C
:\>TITLE EchoArgs 9.78 PRO
Command Line
: test "inscrutable monkey" 5 geronimo
Path 
:        C:\
.
Arguments
0: echoargs
1
: test
2
: "inscrutable monkey"
3
: 5
4
: geronimo
5
:
6
:
7
:
8
:
9
:
Press any key to continue 
. . .

 

Of course, that doesn't tell us anything we didn't already know. The point is that you'd use it to test the commandline settings by temporarily setting echoargs.bat as my external diff / merge tool (in this example) and seeing what's actually going to be passed to the real application when I've got my arguments straight.

 

2 Comments

Comments have been disabled for this content.