Sha256: 2e8a836363fad3512a6711b394aae654d49134caff3c6b27f19c846fd8f13b73

Contents?: true

Size: 748 Bytes

Versions: 5

Compression:

Stored size: 748 Bytes

Contents

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

    def run
      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
        print_usage
      end
    end

    private
    def parse_command(cmd)
      cmd.split(':')
    end
    def print_usage
      puts <<-EOM
Usage: flydata COMMAND
  setup                    # setup initially
      EOM
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
flydata-0.0.1.2011102401 lib/flydata/cli.rb
flydata-0.0.1.2011102303 lib/flydata/cli.rb
flydata-0.0.1.2011102302 lib/flydata/cli.rb
flydata-0.0.1.2011102301 lib/flydata/cli.rb
flydata-0.0.1.2011101801 lib/flydata/cli.rb