require 'thor' module Soaring class SoaringCLI < Thor desc "init [OPTIONS]", "initialize the folder with soar_sc template" option :verbose, :aliases => '-v', :desc => 'Verbose logging' option :project_root, :default => Dir.pwd, :desc => 'Root folder of the soar project, defaults to current folder' option :soar_sc_refspec, :aliases => '-r', :default => 'STABLE', :desc => 'Reference spec (Tag) of soar_sc repo to use for template, defaults to STABLE' def init initializer = Initializer.new(options) initializer.initialize_project end desc "update [OPTIONS]", "update the folder with soar_sc template" option :verbose, :aliases => '-v', :desc => 'Verbose logging' option :project_root, :default => Dir.pwd, :desc => 'Root folder of the soar project, defaults to current folder' option :soar_sc_refspec, :aliases => '-r', :default => 'STABLE', :desc => 'Reference spec (Tag) of soar_sc repo to use for template, defaults to STABLE' def update initializer = Initializer.new(options) initializer.initialize_project end desc "start [OPTIONS]", "start the service component with OPTIONS" option :verbose, :aliases => '-v', :desc => 'Verbose logging' option :project_root, :default => Dir.pwd, :desc => 'Root folder of the soar project, defaults to current folder' option :environment, :aliases => '-e', :default => 'development', :desc => 'Environment in which to execute [development,production]' option :port, :aliases => '-p', :default => '9393', :desc => 'Bind service component server to this port for local run, defaults to 9393' option :autorestart, :desc => 'Keep the service running if it was killed externally or due to exit/exception' def start runner = Runner.new(options) runner.run end desc "stop [OPTIONS]", "stop running rackup instances" option :verbose, :aliases => '-v', :desc => 'Verbose logging' option :killsignal, :aliases => '-k', :default => '9', :desc => 'The signal to send rackup instances INT signal is graceful, defaults to 9 which is not,' def stop exec("for f in $(ps aux | grep rackup | grep -v grep | tr -s ' ' ' ' | cut -d ' ' -f2); do echo killed $f; kill -#{options[:killsignal]} $f; done") end desc "package [OPTIONS]", "package the service component for deployment with OPTIONS" option :verbose, :aliases => '-v', :desc => 'Verbose logging' option :project_root, :default => Dir.pwd, :desc => 'Root folder of the soar project, defaults to current folder' option :ignore_git_checks, :aliases => '-i', :desc => 'Ignore git check to ensure local git repo is committed, defaults to false' def package packager = Packager.new(options) packager.package end desc "detail [OPTIONS]", "provide detailed status of a running service component with OPTIONS" option :verbose, :aliases => '-v', :desc => 'Verbose logging' option :url, :aliases => '-u', :default => 'http://localhost:9393/status-detail', :desc => 'URL of the status endpoint to hit' option :format, :aliases => '-f', :default => 'yaml', :desc => 'The format of the output (yaml,json), defaults to yaml' def detail detailer = Detailer.new(options) detailer.detail end end end