Sha256: 3ef9baf1a58863b7e3d51ff31b28420240bd2847100496abe7223b0861f6d3fd

Contents?: true

Size: 1.18 KB

Versions: 17

Compression:

Stored size: 1.18 KB

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

If you encountered login or any other errors during setup,
please setup flydata again by following commands.
   source ~/.bashrc
   flydata setup

You can check the logs of sender(flydata) process.
   Log path: ~/.flydata/flydata.log

      EOM
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
flydata-0.0.3.8 lib/flydata/cli.rb
flydata-0.0.3.7 lib/flydata/cli.rb
flydata-0.0.3.6 lib/flydata/cli.rb
flydata-0.0.3.5 lib/flydata/cli.rb
flydata-0.0.3.4 lib/flydata/cli.rb
flydata-0.0.3.3 lib/flydata/cli.rb
flydata-0.0.3.2 lib/flydata/cli.rb
flydata-0.0.3.1 lib/flydata/cli.rb
flydata-0.0.3 lib/flydata/cli.rb
flydata-0.0.3.rc1 lib/flydata/cli.rb
flydata-0.0.2.3 lib/flydata/cli.rb
flydata-0.0.2.2 lib/flydata/cli.rb
flydata-0.0.2.1 lib/flydata/cli.rb
flydata-0.0.2 lib/flydata/cli.rb
flydata-0.0.2.rc1 lib/flydata/cli.rb
flydata-0.0.1.2011102901 lib/flydata/cli.rb
flydata-0.0.1.nc2 lib/flydata/cli.rb