Class: Morpheus::Cli::SetPromptCommand

Inherits:
Object
  • Object
show all
Includes:
CliCommand
Defined in:
lib/morpheus/cli/set_prompt_command.rb

Instance Attribute Summary

Attributes included from CliCommand

#no_prompt

Instance Method Summary collapse

Methods included from CliCommand

#build_common_options, #build_option_type_options, #command_name, #default_subcommand, #establish_remote_appliance_connection, #full_command_usage, #handle_subcommand, included, #interactive?, #my_help_command, #my_terminal, #my_terminal=, #parse_id_list, #parse_list_options, #parse_list_subtitles, #print, #print_error, #puts, #puts_error, #raise_command_error, #run_command_for_each_arg, #subcommand_aliases, #subcommand_usage, #subcommands, #usage, #verify_access_token!

Instance Method Details

#handle(args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/morpheus/cli/set_prompt_command.rb', line 11

def handle(args)
  options = {}
  optparse = Morpheus::Cli::OptionParser.new do|opts|
    opts.banner = "Usage: morpheus #{command_name} [shell-prompt]"
    #build_common_options(opts, options, [])
    opts.on('-h', '--help', "Prints this help" ) do
      puts opts
      exit
    end
    opts.footer = <<-EOT
This is intended for use in your morpheus scripts.
It allows you to set the shell prompt.
This can be used as alternative to setting the MORPHEUS_PS1 environment variable

Examples: 
  set-prompt "morpheus $ "
  set-prompt "%cyanmorpheus> "
  set-prompt "[%magenta%remote%reset] %cyan%username morpheus> "

The default prompt is: "%cyanmorpheus> %reset"

EOT
  end
  optparse.parse!(args)

  if args.count != 1
    print_error Morpheus::Terminal.angry_prompt
    puts_error "too many arguments"
    puts_error optparse
    return false
  end
  
  self.my_terminal.prompt = args[0]
  # Morpheus::Terminal.instance.prompt = args[0]
  Morpheus::Cli::Shell.instance.recalculate_prompt()
  # Morpheus::Cli::Echo.recalculate_variable_map()

  return true
end