Class: Whaler::CLI
- Inherits:
-
Object
- Object
- Whaler::CLI
- Defined in:
- lib/whaler/cli.rb
Constant Summary collapse
- EX_USAGE =
64- EX_DATAERR =
65- EX_NOINPUT =
66- GIT_URI =
"[email protected]"
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ CLI
Returns a new instance of CLI.
38 39 40 |
# File 'lib/whaler/cli.rb', line 38 def initialize(args) @args = args end |
Class Method Details
.app(opts) ⇒ Object
16 17 18 |
# File 'lib/whaler/cli.rb', line 16 def self.app(opts) opts[:app] || detect_app end |
.app_opts(command) ⇒ Object
12 13 14 |
# File 'lib/whaler/cli.rb', line 12 def self.app_opts(command) command.on "a=", "app=", "Application" end |
.detect_app ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/whaler/cli.rb', line 20 def self.detect_app apps = Git.open(".").remotes.map do |remote| if m = remote.url.match(/#{GIT_URI}:(.+)\.git/) m[1] end end.uniq if apps.size == 0 $stderr.puts "No app found. Please run whaler from the app folder or use the --app option" exit EX_NOINPUT elsif apps.size > 1 $stderr.puts "Multiple apps found (#{apps.join(", ")}). Please specify one with the --app option" exit EX_DATAERR end apps.first end |