Class: Flydata::Cli
Instance Method Summary collapse
-
#initialize(args) ⇒ Cli
constructor
A new instance of Cli.
- #run ⇒ Object
Methods included from Helpers
development?, env_mode, env_suffix, flydata_api_host_file, flydata_conf_file, format_menu_list, parse_command, print_usage, retry_on, to_command_class
Constructor Details
#initialize(args) ⇒ Cli
Returns a new instance of Cli.
4 5 6 |
# File 'lib/flydata/cli.rb', line 4 def initialize(args) @args = args end |
Instance Method Details
#run ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/flydata/cli.rb', line 8 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 raise e if FLYDATA_DEBUG end end |