Sha256: 63fe417da025bf167edb8cfc2379179e8f5158246be362b93c6c747cae8ada72

Contents?: true

Size: 809 Bytes

Versions: 3

Compression:

Stored size: 809 Bytes

Contents

class Freighthop::CLI; end

require_relative 'cli/help'
require_relative 'cli/ssh'
require_relative 'cli/vagrant'

class Freighthop::CLI
  COMMANDS = [
    Freighthop::CLI::Help,
    Freighthop::CLI::Vagrant,
    Freighthop::CLI::SSH,
  ]

  def initialize(*args)
    @args = args
  end

  def run
    sanity_check
    Freighthop::VagrantEnv.activate!

    command = COMMANDS.detect(lambda{self.help}) { |c| c.match?(*@args) }
    command.new(*@args).run
  end

  def help
    Freighthop::CLI::Help
  end

  def sanity_check
    return if help.match?(*@args)
    unless Freighthop::Config.exist?
      puts <<-NO_CONFIG
ERROR: No freighthop config file (.freighthop.json) found in current path.
       You probably want to check out the README and/or `fh help`.
      NO_CONFIG
      exit 1
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
freighthop-0.2.1 lib/freighthop/cli.rb
freighthop-0.2.0 lib/freighthop/cli.rb
freighthop-0.1.0 lib/freighthop/cli.rb