[TxMt] Re: run script with args

Allan Odgaard throw-away-1 at macromates.com
Sun Oct 15 07:02:37 UTC 2006


On 14. Oct 2006, at 17:21, Matt Neuburg wrote:

>> [...] how about mimicking things by pushing onto ARGV at the top  
>> of the script? That is, use something like
>>
>> ARGV.concat(%w(/etc/file1 /Users/pmccann/file2))
>
> That's an okay idea, but at that point I'd rather just run the  
> script from
> the Terminal, since your approach means (1) I must change the script's
> internals for testing purposes [...]

In this case though you can let the script do something like:

     if ENV['IS_RUNNING_IN_TEXTMATE']
         ARGV.concat(%w(/etc/file1 /Users/pmccann/file2))
     end

And then set IS_RUNNING_IN_TEXTMATE in TextMate’s environment  
variable preferences.

> [...]
> A document is accompanied by metadata called "script arguments" which
> determine the combinations of the perl command, switches, and  
> arguments used
> when running the script. A nice feature of this architecture is  
> that you can
> store many script arguments and then just switch among them as a  
> way of
> testing under different conditions. You might want to steal this  
> idea for
> TextMate... :) m.

It sounds like a good idea -- as Jacob pointed out, we can easily do  
that entirely from bundles, so let’s get someone to do a proof-of- 
concept implementation first, then we can look into if dedicated  
support for something like this is beneficial to have in TM itself.






More information about the textmate mailing list