Module: Mysh

Defined in:
lib/mysh.rb,
lib/mysh/version.rb,
lib/mysh/expression.rb,
lib/mysh/commands/cd.rb,
lib/mysh/smart_source.rb,
lib/mysh/commands/exit.rb,
lib/mysh/commands/help.rb,
lib/mysh/internal/klass.rb,
lib/mysh/internal/parse.rb,
lib/mysh/commands/history.rb,
lib/mysh/internal/decorate.rb,
lib/mysh/internal/instance.rb

Overview

  • internal.rb – mysh internal command instance data and methods.

Defined Under Namespace

Classes: ExecHost, InternalCommand, SmartSource

Constant Summary collapse

VERSION =

The version string of MY SHell.

"0.1.5"
SUMMARY =

A brief summary of this gem.

"mysh -- a Ruby inspired command shell"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.inputObject (readonly)

The input text source.



23
24
25
# File 'lib/mysh.rb', line 23

def input
  @input
end

Class Method Details

.init_runObject

Set up for the run command.



48
49
50
51
52
53
54
# File 'lib/mysh.rb', line 48

def self.init_run
  reset_host
  @input = MiniReadline::Readline.new(history: true,
                                      eoi_detect: true,
                                      auto_complete: true,
                                      auto_source: SmartSource)
end

.reset_hostObject

Reset the state of the execution hosting environment.



57
58
59
# File 'lib/mysh.rb', line 57

def self.reset_host
  @exec_host = ExecHost.new
end

.runObject

The actual shell method.
Endemic Code Smells

  • :reek:TooManyStatements



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/mysh.rb', line 29

def self.run
  init_run

  loop do
    input = @input.readline(prompt: 'mysh> ')

    begin
      @exec_host.execute(input)      ||
      InternalCommand.execute(input) ||
      system(input)
    rescue Interrupt => err
      puts err
    end
  end

  rescue Interrupt, MiniReadlineEOI
end