Sha256: aa5772bd657edab10f8ddccf49d292051db65eb7f2b2e3c7ba08724381dfaca4

Contents?: true

Size: 923 Bytes

Versions: 10

Compression:

Stored size: 923 Bytes

Contents

module Flydata
  class Cli
    include Helpers
    def initialize(args)
      @args = args
    end

    def run
      unless check_environment
        puts "Sorry, you have to run the installation command to use flydata. Please go to https://secure.flydata.co/ and sign up."
        return
      end
      begin
        if @args.size > 0
          first_arg = @args.shift
          cmd, sub_cmd = parse_command(first_arg)
          cmd_cls = "Flydata::Command::#{cmd.capitalize}".constantize
          cmd_obj = cmd_cls.new
          sub_cmd ? cmd_obj.send(sub_cmd) : cmd_obj.run
        else
          raise 'no command given'
        end
      rescue => e
        #raise e
        puts "! #{e.to_s}"
        puts
        puts
        print_usage
      end
    end

    private
    def check_environment
      FileTest.file?(flydata_api_host_file)
    end
    def parse_command(cmd)
      cmd.split(':')
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
flydata-0.0.5.6 lib/flydata/cli.rb
flydata-0.0.5.5 lib/flydata/cli.rb
flydata-0.0.5.4 lib/flydata/cli.rb
flydata-0.0.5.3 lib/flydata/cli.rb
flydata-0.0.5.2 lib/flydata/cli.rb
flydata-0.0.5.1 lib/flydata/cli.rb
flydata-0.0.5.0 lib/flydata/cli.rb
flydata-0.0.4.4 lib/flydata/cli.rb
flydata-0.0.4.3 lib/flydata/cli.rb
flydata-0.0.4.2 lib/flydata/cli.rb