问题
Morning guys,
I am writing a small Ruby CLI app for myself, and I have run into a small issue that I hope you guys can help with. Apologies if this is a stupid question, I am very new to Ruby.
I am using https://github.com/davetron5000/gli as a foundation to build my my app since they make it easy to have all my commands and whatnot.
Question is, while I develop the app, I can run it using bundle exec bin/konstruct
, but that only works from the folder where the code lies.
I want to run the app from a test folder so I can see whether the code I'm adding is doing what it should (make files, remove files, see if directory is empty, etc).
When I played around with NodeJS, I could link the app, and it would work anywhere. Is there something like that for Ruby apps that are still in development?
回答1:
Two simple way:
1. Make bin/konstruct
executable. So you can run it without bundle exec
. Then link it in any directory in your $PATH
with ln -s
. (For Unix based systems)
2. Create a alias in your shell. something like this:
alias konstruct="bundle exec /FULL/PATH/TO/bin/konstruct"
(Also for Unix based systems)
来源:https://stackoverflow.com/questions/34626386/how-can-i-test-my-ruby-cli-app-while-still-in-development