bin/vanity in vanity-1.6.1 vs bin/vanity in vanity-1.7.0
- old
+ new
@@ -1,69 +1,16 @@
#!/usr/bin/env ruby
-# Is there a better way to detect Rails?
-if File.exist?("config/boot.rb") && File.exist?("config/environment.rb")
- require "config/environment"
-else
- path = File.expand_path("../lib", File.dirname(__FILE__))
- $LOAD_PATH.unshift path unless $LOAD_PATH.include?(path)
- require "vanity"
-end
+#
+# This file was generated by Bundler.
+#
+# The application 'vanity' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
-require "optparse"
+require 'pathname'
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
-playground = Vanity.playground
-options = Struct.new(:output).new
-opts = OptionParser.new("", 24, " ") do |opts|
- opts.banner = "Usage: #{File.basename($0)} [options] command\n"
- opts.banner << "Commands:\n"
- opts.banner << " list List all experiments and metrics\n"
- opts.banner << " report Report on all running experiments/metrics\n"
- opts.banner << " upgrade Upgrade your database when deploying new release\n"
+require 'rubygems'
+require 'bundler/setup'
- opts.separator ""
- opts.separator "Reporting options:"
- opts.on "--output FILE", "Write report to this file (default: stdout)" do |path|
- options.output = path
- end
-
- opts.separator ""
- opts.separator "Common options:"
- opts.on "--load_path PATH", "Path to experiments directory (default: #{playground.load_path})" do |path|
- playground.load_path = path
- end
- opts.on "-d", "--database url", "Database connection URL (e.g. redis:/localhost:6379)" do |conn|
- playground.establish_connection conn
- end
- opts.on "--redis HOST:PORT:DB", "DEPRECATED: Redis server host (default: localhost:6379)" do |redis|
- host, port, db = redis.split(":")
- playground.establish_connection "redis:/#{host}:#{port}/#{db}"
- end
- opts.on_tail "-h", "--help", "Show this message" do
- puts opts.to_s.gsub(/^.*DEPRECATED.*$/s, '')
- exit
- end
- opts.on_tail "-v", "--version", "Show version" do
- puts "Vanity #{Vanity::Version::STRING}"
- exit
- end
-end
-
-opts.parse!(ARGV)
-if ARGV.empty?
- puts opts.banner
- exit
-end
-
-ARGV.each do |cmd|
- case cmd
- when "report"
- require "vanity/commands/report"
- Vanity::Commands.report options.output
- when "list"
- require "vanity/commands/list"
- Vanity::Commands.list
- when "upgrade"
- require "vanity/commands/upgrade"
- Vanity::Commands.upgrade
- else fail "No such command: #{cmd}"
- end
-end
+load Gem.bin_path('vanity', 'vanity')