简体   繁体   中英

Get command line current folder in ruby gem

I'm writing a small ruby gem which should generate couple of files, so I'm using executables.

How can I (in my ruby code) get the current folder of the command line from which the gem was executed?

For example, when I run my tool in this path:

~/Projects/MyProject/ $ my-tool

How can I get the ~/Projects/MyProject/ in my ruby code?

Thank you

Dir.pwd or Dir.getwd should do. Please note they return full absolute path, with ~ expanded.

https://ruby-doc.org/core-2.5.0/Dir.html#method-c-pwd

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM