Class: Cs::Service::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/cs/service/cli.rb

Overview

Cli

Constant Summary collapse

ENVS =

rubocop:disable ClassLength

%w(REST_SERVER_ROOT TRADING_SERVER_ROOT RAILS_ROOT RACK_ENV).freeze
PROJECTS =
%w( rest_server trading_server web).freeze
CONFIG_FILES =
{
  web: ENV['RAILS_ROOT'],
  trading_server: ENV['TRADING_SERVER_ROOT'],
  rest_server: ENV['REST_SERVER_ROOT']
}

Instance Method Summary collapse

Instance Method Details

#env(env_name = nil) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/cs/service/cli.rb', line 35

def env(env_name = nil)
  if env_name.nil?
    print_env
  elsif ENV[env_name]
    puts "#{env_name}=#{ENV[env_name]}"
  else
    say "#{env_name} is blank", :yellow
  end
  say "\nConfig Files:"
  fetch_config_files
  say "详见 cs-service help env"
end

#help(command = nil, subcommand = false) ⇒ Object



80
81
82
83
# File 'lib/cs/service/cli.rb', line 80

def help(command = nil, subcommand = false)
  say Motd.msg unless command
  super(command, subcommand)
end

#info(name = nil) ⇒ Object



49
50
51
52
# File 'lib/cs/service/cli.rb', line 49

def info(name = nil)
  # invoke(:env)
  run_eye(:info, name)
end

#load_confObject



21
22
23
24
25
# File 'lib/cs/service/cli.rb', line 21

def load_conf
  invoke(:env)
  quit if options[:force]
  run_eye(:load, File.join(HOME_PATH, 'config/caishuo.eye'))
end

#log(project = nil) ⇒ Object



75
76
77
# File 'lib/cs/service/cli.rb', line 75

def log(project = nil)
  run_eye(:trace, project || PROJECTS)
end

#quitObject



69
70
71
72
# File 'lib/cs/service/cli.rb', line 69

def quit
  stop
  run_eye(:quit)
end

#versionObject



86
87
88
# File 'lib/cs/service/cli.rb', line 86

def version
  say Cs::Service::VERSION, :green
end