Class: Dapp::Dimg::CLI::Command::Dimg::Run
- Inherits:
-
Base
- Object
- CLI
- CLI::Command::Base
- Base
- Dapp::Dimg::CLI::Command::Dimg::Run
- Extended by:
- CLI::Options::Ssh
- Defined in:
- lib/dapp/dimg/cli/command/dimg/run.rb
Constant Summary
Constants inherited from Base
Base::DIMG_STAGES, Base::STAGE_PROC
Constants inherited from CLI
Instance Method Summary collapse
- #expected_options ⇒ Object
- #find_option(arg) ⇒ Object
- #log_running_time ⇒ Object
- #read_options(args) ⇒ Object
- #run(argv = ARGV) ⇒ Object
Methods included from CLI::Options::Ssh
Methods inherited from CLI::Command::Base
#cli_options, #initialize, #log_dapp_running_time, #run_dapp_command, #run_method
Methods inherited from CLI
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
#check_path?, #check_subpath?, #class_to_lowercase, class_to_lowercase, #delete_file, #ignore_path?, #ignore_path_base, #kwargs, #make_path, #path_checker, #search_file_upward
Constructor Details
This class inherits a constructor from Dapp::CLI::Command::Base
Instance Method Details
#expected_options ⇒ Object
45 46 47 |
# File 'lib/dapp/dimg/cli/command/dimg/run.rb', line 45 def @expected_options ||= .values.map { |opt| { formats: [opt[:long], opt[:short]].compact, with_arg: !opt[:long].split.one? } } end |
#find_option(arg) ⇒ Object
40 41 42 43 |
# File 'lib/dapp/dimg/cli/command/dimg/run.rb', line 40 def find_option(arg) .each { |hash| return hash if hash[:formats].any? { |f| f.start_with? arg } } nil end |
#log_running_time ⇒ Object
68 69 70 |
# File 'lib/dapp/dimg/cli/command/dimg/run.rb', line 68 def log_running_time false end |
#read_options(args) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/dapp/dimg/cli/command/dimg/run.rb', line 23 def (args) self.class.cli_wrapper(self) do args.each_with_index do |arg, i| next if arg == '--' next if (key = find_option(arg)).nil? cli_option = [] cli_option << args.slice!(i) if key[:with_arg] raise OptionParser::InvalidOption if args.count < i + 1 cli_option << args.slice!(i) end (cli_option) return (args) end end end |
#run(argv = ARGV) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/dapp/dimg/cli/command/dimg/run.rb', line 49 def run(argv = ARGV) filtered_args = (argv) patterns = filtered_args.any? && !filtered_args.first.start_with?('-') ? [filtered_args.shift] : [] index = filtered_args.index('--') || filtered_args.count = index.nonzero? ? filtered_args.slice(0..index - 1) : [] command = filtered_args.slice(index + 1..-1) || [] if .empty? && command.empty? = %w(-ti --rm) command = %w(/bin/bash) end stage_name = config.delete(:stage) run_dapp_command(nil, options: (dimgs_patterns: patterns)) do |dapp| dapp.run(stage_name, , command) end end |