Class: Dapp::CLI::Command::Base
- Defined in:
- lib/dapp/cli/command/base.rb
Direct Known Subclasses
Slug, Deployment::CLI::Command::Base, Dimg::CLI::Command::Base, Kube::CLI::Command::Base
Constant Summary
Constants inherited from Dapp::CLI
Instance Method Summary collapse
- #cli_options(**kwargs) ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #log_dapp_running_time(dapp, ignore: false) ⇒ Object
- #run(_argv = ARGV) ⇒ Object
- #run_dapp_command(run_method, options: {}, log_running_time: true, try_host_docker_login: false) ⇒ Object
Methods included from Helper::Cli
#cli_wrapper, #composite_options, #in_validate!, #list_msg_format, #parse_options, #parse_subcommand, #prepare_subcommand, #print_error_with_help_and_die!, #required_argument, #run_subcommand
Methods included from Helper::Trivia
class_to_lowercase, #class_to_lowercase, #delete_file, #kwargs, #make_path, #search_file_upward
Constructor Details
Instance Method Details
#cli_options(**kwargs) ⇒ Object
92 93 94 95 96 97 98 99 |
# File 'lib/dapp/cli/command/base.rb', line 92 def (**kwargs) dirs = [config[:build_dir], config[:run_dir], config[:deploy_dir]] if dirs.compact.size > 1 self.class.print_error_with_help_and_die! self, "cannot use alias options --run-dir, --build-dir, --deploy-dir at the same time" end config.merge(build_dir: dirs.compact.first, **kwargs) end |
#log_dapp_running_time(dapp, ignore: false) ⇒ Object
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/dapp/cli/command/base.rb', line 77 def log_dapp_running_time(dapp, ignore: false) return yield if ignore begin start_time = Time.now yield ensure dapp.log_step("Running time #{(Time.now - start_time).round(2)} seconds") end end |
#run(_argv = ARGV) ⇒ Object
88 89 90 |
# File 'lib/dapp/cli/command/base.rb', line 88 def run(_argv = ARGV) raise end |
#run_dapp_command(run_method, options: {}, log_running_time: true, try_host_docker_login: false) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/dapp/cli/command/base.rb', line 59 def run_dapp_command(run_method, options: {}, log_running_time: true, try_host_docker_login: false) dapp = ::Dapp::Dapp.new(options: ) log_dapp_running_time(dapp, ignore: !log_running_time) do begin dapp.try_host_docker_login if try_host_docker_login if block_given? yield dapp elsif !run_method.nil? dapp.public_send(run_method) end ensure dapp.terminate end end end |