Last active
May 28, 2024 15:02
-
-
Save TomV/5680864 to your computer and use it in GitHub Desktop.
Simple Terminal for Locomotive!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simple script to invoke locomotive | |
* uses the jake-lcm module: https://npmjs.org/package/jake-lcm | |
* | |
* Just put this at the root of your locomotive app | |
* | |
* Date: 5/30/13 | |
* | |
*/ | |
var lcm = require('jake-lcm') | |
, repl = require('repl'); | |
// More about jake-lcm here: https://github.com/drudge/jake-lcm | |
lcm.exec( | |
{ | |
initializers: ['00_generic', '02_mongoose', '03_models'] | |
}, | |
function () { | |
repl.start({ | |
prompt: "Locomotive: > ", | |
input: process.stdin, | |
output: process.stdout | |
}); | |
} | |
); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's a quick example of using it:
In my 00_generic initializer I set up a global container, myapp:
In the example above, I just loaded the 03_models initialzier, so now I can create and test a user:
That dumps the whole mongoose User object to the terminal, so you can do this instead:
Next, create a user in the terminal:
Works pretty well for me.