Class: Appbundler::CLI
- Inherits:
-
Object
- Object
- Appbundler::CLI
- Includes:
- Mixlib::CLI
- Defined in:
- lib/appbundler/cli.rb
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
-
#bin_path ⇒ Object
readonly
Returns the value of attribute bin_path.
-
#bundle_path ⇒ Object
readonly
Returns the value of attribute bundle_path.
-
#gems ⇒ Object
readonly
Returns the value of attribute gems.
Class Method Summary collapse
Instance Method Summary collapse
- #err(message) ⇒ Object
- #handle_options ⇒ Object
-
#initialize(argv) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
- #usage_and_exit! ⇒ Object
- #validate! ⇒ Object
- #verify_bin_path ⇒ Object
- #verify_bundle_path ⇒ Object
Constructor Details
#initialize(argv) ⇒ CLI
Returns a new instance of CLI.
60 61 62 63 |
# File 'lib/appbundler/cli.rb', line 60 def initialize(argv) @argv = argv super() end |
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
54 55 56 |
# File 'lib/appbundler/cli.rb', line 54 def argv @argv end |
#bin_path ⇒ Object (readonly)
Returns the value of attribute bin_path.
57 58 59 |
# File 'lib/appbundler/cli.rb', line 57 def bin_path @bin_path end |
#bundle_path ⇒ Object (readonly)
Returns the value of attribute bundle_path.
56 57 58 |
# File 'lib/appbundler/cli.rb', line 56 def bundle_path @bundle_path end |
#gems ⇒ Object (readonly)
Returns the value of attribute gems.
58 59 60 |
# File 'lib/appbundler/cli.rb', line 58 def gems @gems end |
Class Method Details
.run(argv) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/appbundler/cli.rb', line 47 def self.run(argv) cli = new(argv) cli. cli.validate! cli.run end |
Instance Method Details
#err(message) ⇒ Object
111 112 113 |
# File 'lib/appbundler/cli.rb', line 111 def err() $stderr.print("#{}\n") end |
#handle_options ⇒ Object
65 66 67 |
# File 'lib/appbundler/cli.rb', line 65 def (@argv) end |
#run ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/appbundler/cli.rb', line 99 def run gems.each do |g| app = App.new(bundle_path, bin_path, g) created_stubs = app.write_executable_stubs created_stubs.each do |real_executable_path, stub_path| $stdout.puts "Generated binstub #{stub_path} => #{real_executable_path}" end created_lockfile = app.write_merged_lockfiles(without: config[:without]) $stdout.puts "Generated merged lockfile at #{created_lockfile}" if created_lockfile end end |
#usage_and_exit! ⇒ Object
115 116 117 118 |
# File 'lib/appbundler/cli.rb', line 115 def usage_and_exit! err() exit 1 end |
#validate! ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/appbundler/cli.rb', line 69 def validate! if cli_arguments.size < 2 usage_and_exit! else @bundle_path = File.(cli_arguments[0]) @bin_path = File.(cli_arguments[1]) @gems = cli_arguments[2..-1] @gems = [ nil ] if @gems.empty? verify_bundle_path verify_bin_path end end |
#verify_bin_path ⇒ Object
92 93 94 95 96 97 |
# File 'lib/appbundler/cli.rb', line 92 def verify_bin_path if !File.directory?(bin_path) err("BINSTUB_DIR `#{bin_path}' is not a directory or doesn't exist") usage_and_exit! end end |
#verify_bundle_path ⇒ Object
82 83 84 85 86 87 88 89 90 |
# File 'lib/appbundler/cli.rb', line 82 def verify_bundle_path if !File.directory?(bundle_path) err("BUNDLE_DIR `#{bundle_path}' is not a directory or doesn't exist") usage_and_exit! elsif !File.exist?(File.join(bundle_path, "Gemfile.lock")) err("BUNDLE_DIR does not contain required Gemfile.lock") usage_and_exit! end end |