As I develop useful one-liners, it'd be handy to be able to run meteor shell
, passing it the one-liner, and expecting that it will exit when done. Some syntax such as this, perhaps ?
meteor shell -e 'Meteor.users.remove({})'
Is this a feature request, or does it already exist already ?
Supplemental: I picture adding several of these scripts to package.json
so they can be shared by all developers on the project.
Here's an Expect program for scripting the Meteor shell. You can either run a separate file or run a command directly. Usage:
./mshell -f runThisFile.js
./mshell -e 'console.log("foo")'
Here's the code (License: MIT). Save to a file (mshell
, or whatever you choose) and make executable:
#!/usr/bin/expect --
set timeout 3
spawn meteor shell
expect "> "
set firstArg [lindex $argv 0]
set secondArg [lindex $argv 1]
if { $firstArg == "-f" } {
send [exec cat $secondArg]
send "\n"
} elseif { $firstArg == "-e" } {
send "$secondArg\n"
}
expect "true"
send "\x04"
expect "Shell exiting...\n"
On Ubuntu I ran sudo apt-get install expect
to install Expect prior to running this program.
Clearly we'd rather running scripts or one-liners were built into meteor shell
, so let's just consider this a proof-of-concept.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With