Method: Morpheus::Cli::CliRegistry.exec_alias

Defined in:
lib/morpheus/cli/cli_registry.rb

.exec_alias(alias_name, args) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/morpheus/cli/cli_registry.rb', line 88

def exec_alias(alias_name, args)
  found_alias_command = instance.get_alias(alias_name)
  if !found_alias_command
    raise Morpheus::Cli::CommandError.new("'#{alias_name}' is not a defined alias.")
  end
  # if !is_valid_expression(found_alias_command)
  #   raise Morpheus::Cli::CommandError.new("alias '#{alias_name}' is not a valid expression: #{found_alias_command}")
  # end
  input = found_alias_command
  if args && !args.empty?
    input = "#{found_alias_command} " + args.collect {|arg| arg.include?(" ") ? "\"#{arg}\"" : "#{arg}" }.join(" ")
  end
  exec_expression(input)
end