Sha256: a5efe1f4530f021fcb2229d2070adb84b43e1804638e75e96f3ae1cf71ac10d1

Contents?: true

Size: 969 Bytes

Versions: 3

Compression:

Stored size: 969 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
  start                    # start flydata process
  stop                     # stop flydata process
  restart                  # restart flydata process
  setlogdel                # show and change log deletion settting
      EOM
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flydata-0.0.1.nc1 lib/flydata/cli.rb
flydata-0.0.1.2011102602 lib/flydata/cli.rb
flydata-0.0.1.2011102601 lib/flydata/cli.rb