Class: Yarsh::Shell
- Inherits:
-
Object
- Object
- Yarsh::Shell
- Includes:
- Yarsh, InstanceMethods
- Defined in:
- lib/yarsh/shell.rb
Constant Summary collapse
- SHELL_BUILTINS =
%w[alias bg bind break builtin command echo eval exec exit export false fc fg getopts hash help history jobs kill let local logout mapfile popd printf pushd pwd read readonly return set shift shopt source suspend test times trap true type typeset ulimit umask unalias unset wait].freeze
Constants included from InstanceMethods
Constants included from Yarsh
CONFIG_FILE, HISTORY_FILE, VERSION, YARSH_DIR
Instance Attribute Summary collapse
-
#bind ⇒ Object
Returns the value of attribute bind.
Instance Method Summary collapse
-
#initialize(bind) ⇒ Shell
constructor
A new instance of Shell.
- #shell ⇒ Object
Methods included from InstanceMethods
#__sh__, #__yarsh__, #configure, #sh_alias, #source
Methods included from Yarsh
console, current_shell, current_shell=, execute_system_command, expand_aliases, #shell_path?
Constructor Details
#initialize(bind) ⇒ Shell
Returns a new instance of Shell.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/yarsh/shell.rb', line 16 def initialize(bind) @bind = bind @core = Reline.core @history_file = File.(HISTORY_FILE) @config_file = File.(CONFIG_FILE) @cf = Yarsh::AnsiColorFormatter.new Yarsh.current_shell = self setup_reline_history setup_reline_completion setup_reline_prompt end |
Instance Attribute Details
#bind ⇒ Object
Returns the value of attribute bind.
8 9 10 |
# File 'lib/yarsh/shell.rb', line 8 def bind @bind end |
Instance Method Details
#shell ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/yarsh/shell.rb', line 28 def shell # TODO: defined method in the config file should be availabel in the shell load @config_file, InstanceMethods if File.exist? @config_file loop do input = begin read_input rescue Interrupt next end if input.nil? or input == 'exit' puts 'Bye...' break end append_history(input, @history_file) begin fp execute_multiline(input) rescue Interrupt next rescue SystemExit raise rescue Exception => e $rber = e puts @cf.fg_red("Error: #{e.class}: #{e.}\n#{e.backtrace.join("\n")}") end end end |