Stand-alone cli that loads a rails app?
I am trying to write a standalone cli app that loads a rails app and uses its code (orm, etc), but handles its own args processing. This article is a good overview of how command line arguments are second class citizens with rake tasks. What I would like to do is manually load the rails app/env/config as part of the execution of my cli, so I can provide a decent cli interface for this tool.
Can anyone point to a good, self-contained example of code that does the proper initialization for this purpose? Like, the code that runs to setup rails console, in one place. Thanks for any assistance you can provide!
3 comments · 100% upvoted · other discussions
You can run a custom script via:
Though it should suffice to use
In your script directly (if said script is located in Rails.root)
localhostdotdev 2 points · May 2019
``` require 'config/environment'
=> cannot load such file -- config/environment
require_relative "config/environment"
works
```
jstrong [OP] 1 points · May 2019
thanks! all examples of runner I had found passed the string of a code path (inside the rails app), but if I can pass the filename that would work well, I think.