class Steep::CLI

def process_binstub

def process_binstub
  path = Pathname("bin/steep")
  root_path = Pathname.pwd
  force = false
  OptionParser.new do |opts|
    opts.banner = <<BANNER
e: steep binstub [options]
ription:
Generate a binstub which set up ruby executables and bundlers.
ons:
ER
    handle_logging_options opts
    opts.on("-o PATH", "--output=PATH", "The path of the executable file (defaults to `bin/steep`)") do |v|
      path = Pathname(v)
    end
    opts.on("--root=PATH", "The repository root path (defaults to `.`)") do |v|
      root_path = (Pathname.pwd + v).cleanpath
    end
    opts.on("--[no-]force", "Overwrite file (defaults to false)") do
      force = true
    end
  end.parse!(argv)
  binstub_path = (Pathname.pwd + path).cleanpath
  bindir_path = binstub_path.parent
  bindir_path.mkpath
  gemfile_path =
    if defined?(Bundler)
      Bundler.default_gemfile.relative_path_from(bindir_path)
    else
      Pathname("../Gemfile")
    end
  if binstub_path.file?
    if force
      stdout.puts Rainbow("#{path} already exists. Overwriting...").yellow
    else
      stdout.puts Rainbow(''"⚠️ #{path} already exists. Bye! 👋").red
      return 0
    end
  end
  template = <<TEMPLATE
sr/bin/env bash
TUB_DIR=$(cd $(dirname $0); pwd)
ILE=$(readlink -f ${BINSTUB_DIR}/#{gemfile_path})
_DIR=$(readlink -f ${BINSTUB_DIR}/#{root_path.relative_path_from(bindir_path)})
P="bundle exec --gemfile=${GEMFILE} steep"
ype "rbenv" > /dev/null 2>&1; then
EEP="rbenv exec ${STEEP}"

 type "rvm" > /dev/null 2>&1; then
if [ -e ${ROOT_DIR}/.ruby-version ]; then
  STEEP="rvm ${ROOT_DIR} do ${STEEP}"
fi

 $STEEP $@
LATE
  binstub_path.write(template)
  binstub_path.chmod(0755)
  stdout.puts Rainbow("Successfully generated executable #{path} 🎉").blue
  0
end