Class: Installation::Console::Commands
- Inherits:
-
Object
- Object
- Installation::Console::Commands
- Includes:
- Yast::I18n
- Defined in:
- src/lib/installation/console/plugins/shell_command.rb,
src/lib/installation/console/commands.rb
Overview
define the "shell" command in the expert console
Instance Method Summary collapse
-
#commands ⇒ Object
print the available commands.
-
#initialize(console) ⇒ Commands
constructor
This class implements the commands in the installer console, the actual commands are implemented as plugins loaded from lib/installation/console/plugins/*.rb files.
-
#method_missing(method_name, *_args) ⇒ Object
all unknown commands are handled via this "method_missing" callback.
- #respond_to_missing?(_method_name, _include_private = false) ⇒ Boolean
-
#run_yast_module(*args) ⇒ Object
helper for running an YaST module.
- #shell ⇒ Object
-
#welcome ⇒ Object
print the "welcome" message with a basic help text.
Constructor Details
#initialize(console) ⇒ Commands
This class implements the commands in the installer console, the actual commands are implemented as plugins loaded from lib/installation/console/plugins/*.rb files
All public methods in this class are the commands available in the console, that means we cannot include Yast::Logger here because it would define "log" command. For logging we have to use the full form here, e.g. Yast::Y2Logger.instance.info
33 34 35 36 37 38 |
# File 'src/lib/installation/console/commands.rb', line 33 def initialize(console) textdomain "installation" @console = console Plugins.load_plugins end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *_args) ⇒ Object
all unknown commands are handled via this "method_missing" callback
77 78 79 80 81 82 |
# File 'src/lib/installation/console/commands.rb', line 77 def method_missing(method_name, *_args) Yast::Y2Logger.instance.info "Entered unknown command: #{method_name.inspect}" puts "Error: Unknown command \"#{method_name}\"" puts commands end |
Instance Method Details
#commands ⇒ Object
print the available commands
64 65 66 67 68 69 70 71 72 73 74 |
# File 'src/lib/installation/console/commands.rb', line 64 def commands puts "Available commands:" puts print_command("quit", "Close the console and return back to the installer") private_methods.grep(/_description$/).sort.each do |method| print_command(method.to_s.sub(/_description$/, ""), send(method)) end puts end |
#respond_to_missing?(_method_name, _include_private = false) ⇒ Boolean
84 85 86 87 88 |
# File 'src/lib/installation/console/commands.rb', line 84 def respond_to_missing?(_method_name, _include_private = false) # method missing is not used for fancy meta programming, # but to provide different behavior. Not to respond to anything missing. false end |
#run_yast_module(*args) ⇒ Object
helper for running an YaST module
91 92 93 |
# File 'src/lib/installation/console/commands.rb', line 91 def run_yast_module(*args) @console.run_yast_module(*args) end |
#shell ⇒ Object
18 19 20 21 22 23 24 |
# File 'src/lib/installation/console/plugins/shell_command.rb', line 18 def shell if Yast::UI.TextMode tui_shell else gui_shell end end |
#welcome ⇒ Object
print the "welcome" message with a basic help text
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'src/lib/installation/console/commands.rb', line 41 def welcome puts "---- This is the YaST Installation Console ----" puts # this is the most important message so make it translatable, # the console is for experts so it is OK have the rest untranslated # TRANSLATORS: help text displayed in the installer command line console, # do not change these texts they are replaced: # %{cmd} is replaced by a command name # %{keys} is replaced by a keyboard shortcut puts format(_("Type '%{cmd}' or press %{keys} to close the console and go back " \ "to the installer"), cmd: "quit", keys: "Ctrl+D") puts puts "Type 'commands' to see the available special commands" puts puts "This is a Ruby shell, you can also type any Ruby command here" puts "and inspect or change the YaST installer" puts puts "Hints: <Tab> completion is enabled, the command history is kept," puts "you can use the usual \"readline\" features..." puts end |