Class: Morpheus::Cli::EditProfileCommand
- Inherits:
-
Object
- Object
- Morpheus::Cli::EditProfileCommand
- Includes:
- CliCommand
- Defined in:
- lib/morpheus/cli/commands/standard/edit_profile_command.rb
Overview
Command for editing the .morpheus_profile initalization script
Instance Attribute Summary
Attributes included from CliCommand
Instance Method Summary collapse
-
#handle(args) ⇒ Object
set_command_hidden.
Methods included from CliCommand
#apply_options, #build_common_options, #build_option_type_options, #build_standard_add_options, #build_standard_delete_options, #build_standard_get_options, #build_standard_list_options, #build_standard_post_options, #build_standard_put_options, #build_standard_remove_options, #build_standard_update_options, #command_name, #default_refresh_interval, #default_subcommand, #establish_remote_appliance_connection, #full_command_usage, #get_subcommand_description, #handle_subcommand, included, #interactive?, #my_help_command, #my_terminal, #my_terminal=, #parse_bytes_param, #parse_id_list, #parse_list_options, #parse_list_subtitles, #parse_passed_options, #parse_payload, #parse_query_options, #print, #print_error, #println, #puts, #puts_error, #raise_args_error, #raise_command_error, #render_response, #render_with_format, #run_command_for_each_arg, #subcommand_aliases, #subcommand_description, #subcommand_usage, #subcommands, #usage, #verify_args!, #visible_subcommands
Instance Method Details
#handle(args) ⇒ Object
set_command_hidden
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 |
# File 'lib/morpheus/cli/commands/standard/edit_profile_command.rb', line 11 def handle(args) = {} editor = ENV['EDITOR'] || 'nano' filename = Morpheus::Cli::DotFile.morpheus_profile_filename optparse = Morpheus::Cli::OptionParser.new do|opts| opts. = "Usage: morpheus #{command_name}" opts.on( '-e', '--editor PROGRAM', "Editor program to use. The default is $EDITOR." ) do |val| editor = val end (opts, , []) opts. = "Edit your interactive shell script at #{filename}" end optparse.parse!(args) if !editor print_error Morpheus::Terminal.angry_prompt puts_error "You have not defined an EDITOR." puts_error "Try export EDITOR=emacs" #puts "Trying nano..." #editor = "nano" return 1 end puts "opening #{filename} for editing" system(editor, filename) if !$?.success? print_error Morpheus::Terminal.angry_prompt puts_error "edit command failed with #{$?.exitstatus}: #{editor} #{filename}" return $?.exitstatus end if Morpheus::Cli::Shell.has_instance? puts "use 'reload' to re-execute your startup script" end return 0 # $? end |