Sorry for the newbie question, but how do I run the script I'm looking at, with arguments? For example I'm editing a Ruby script and I want to run it, supplying a filename that the script is to pick up as ARGV[0] and read. I can't believe that the answer is "use the Terminal"; surely I can stay in TextMate and do this, in some way that I'm just failing to see. Thx - m.
Allan wrote,
[...] but how do I run the script I'm looking at, with arguments? [...]
No way to do that, my reply form last time this came up http:// lists.macromates.com/pipermail/textmate/2006-September/013015.html
Perhaps I'm missing the point here (seems to be a habit these days), but 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))
For example: ======================================================================= #!/usr/bin/env ruby -w
ARGV.concat(%w(/etc/passwd /Users/pmccann/.zshrc)) # Stack 'em on...
# And now use ARGV as per usual...
ARGV.each do |file| str = IO.readlines(file) puts "\nThere are #{str.length} lines in #{file}" puts "Here are the first 5:" puts "#{str[0..4]}\n" end
=======================================================================
That seems to run identically (under command-R) to what happens if I save the "unstacked" version into file.rb and use
./file.rb /etc/passwd /Users/pmccann/.zshrc
on the command line.
Regards, Paul
On 10/14/06 12:03 AM, in article CD129D28-B3B6-4F25-9C79-5B71F45BDD66@adelaide.edu.au, "Paul McCann" paul.mccann@adelaide.edu.au wrote:
Allan wrote,
[...] but how do I run the script I'm looking at, with arguments? [...]
No way to do that, my reply form last time this came up http:// lists.macromates.com/pipermail/textmate/2006-September/013015.html
but 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, and (2) this is part of a larger problem that can't be solved quite so easily.
Allan, if you're still reading, you might want to look at how the Perl IDE/Debugger Affrus solves this problem:
http://www.latenightsw.com/affrus/index.html
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.
Matt Neuburg wrote:
Allan, if you're still reading, you might want to look at how the Perl IDE/Debugger Affrus solves this problem:
http://www.latenightsw.com/affrus/index.html
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.
You could make something like this by attaching your own xattrs to the file, and then a 'run script' command that takes a look at those. There's a python module for modifying xattrs, though I doubt it works on all filesystems (IIRC allan had to work around some weird bugs on that front).
In any case, this doesn't have to be something built into textmate. The bundles are perfectly capable of taking care of it.
-Jacob
On 10/14/06 9:13 AM, in article egr2b2$ilr$1@sea.gmane.org, "Jacob Rus" jrus@hcs.harvard.edu wrote:
Matt Neuburg wrote:
Allan, if you're still reading, you might want to look at how the Perl IDE/Debugger Affrus solves this problem:
http://www.latenightsw.com/affrus/index.html
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.
You could make something like this by attaching your own xattrs to the file, and then a 'run script' command that takes a look at those. There's a python module for modifying xattrs, though I doubt it works on all filesystems (IIRC allan had to work around some weird bugs on that front).
In any case, this doesn't have to be something built into textmate. The bundles are perfectly capable of taking care of it.
Cool idea, I'll look into it. Thx - m.
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.