Class: Jets::CLI::Exec::Repl
- Inherits:
-
Object
- Object
- Jets::CLI::Exec::Repl
- Extended by:
- Memoist
- Includes:
- Util::Logging
- Defined in:
- lib/jets/cli/exec/repl.rb,
lib/jets/cli/exec/repl/history.rb
Defined Under Namespace
Classes: History
Instance Attribute Summary collapse
-
#history ⇒ Object
readonly
Returns the value of attribute history.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Repl
constructor
A new instance of Repl.
- #start ⇒ Object
Methods included from Util::Logging
Constructor Details
Instance Attribute Details
#history ⇒ Object (readonly)
Returns the value of attribute history.
10 11 12 |
# File 'lib/jets/cli/exec/repl.rb', line 10 def history @history end |
Instance Method Details
#start ⇒ Object
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 50 51 52 |
# File 'lib/jets/cli/exec/repl.rb', line 17 def start welcome loop do input = Readline.readline("$ ", true) if input.nil? || input.downcase == "exit" puts "Exiting..." history.save break elsif input.strip.empty? next elsif input.strip.start_with? "history" num = input.split(" ")[1] history.display(num) next elsif input.strip.start_with? "!" execute_from_history(input) next elsif input.strip == "status" display_last_status next elsif %w[_ result].include?(input.strip) display_last_result next elsif %w[help ?].include?(input.strip) display_help next end if history.list.empty? || input != history.list.last history.add(input) end execute_command(input) end end |