How can I test my Ruby CLI app while still in deve

2019-09-05 22:06发布

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条回答
何必那么认真
2楼-- · 2019-09-05 22:49

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)

查看更多
登录 后发表回答