Question: I want make interactive application where user launches it and can do various task by typing commands (some kind of shell)

example:  

```
./myapp.rb  
App says Hi  
Commands:   
  help - display help about command
  open - open task
  do - do action
Start>help open
  open <TaskName>
  opens specified task
Start>open Something  
Something>do SomeAction
  Success!
Something> (blinking cursor here)

```

I searched but couldn't find any ruby gems that I could use specially for console interaction, so I'm about to my make my own...

I looked at [Thor](https://www.ruby-toolbox.com/projects/thor), but that's not exactly as I want, maybe I could use it, but not sure...

it could look something like:

```
class Tasks
  attr_reader :opened_task

  desc "open <TaskName>", "opens specified task"
  def open(params)
  end

  desc "do <ActionName>", "do specified action"
  def do(params)
  end
end

tasks = Tasks.new
# theoretical Console class
console = Console.new
console.addCommand("open",tasks.method(:open),"open task")
console.addCommand("do",tasks.method(:do),"do action")
console.start("%s>",[*tasks.opened_task])

```

so my question is, what gems I could use to make such console class? maybe someone have already made something similar?
I plan using [HighLine](https://www.ruby-toolbox.com/gems/highline) for input/output, but any other suggestion what could I use?

Answer: 
What you want is a [REPL](http://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop) – `Read → Evaluate → Print Loop`.

IRB, for example, implements a REPL for the Ruby language.

Here's a very simple implementation of your application's REPL:

```
loop do
  Application::Console.prompt.display
  input = gets.chomp
  command, *params = input.split /\s/

  case command
  when /\Ahelp\z/i
    puts Application::Console.help_text
  when /\Aopen\z/i
    Application::Task.open params.first
  when /\Ado\z/i
    Application::Action.perform *params
  else puts 'Invalid command'
  end
end

```

`\A` and `\z` match the start of the string and the end of the string, respectively.
You could also try [ripl](https://github.com/cldwalker/ripl). (from the documentation): 
Creating and starting a custom shell is as simple as:

```
require 'ripl'
# Define plugins, load files, etc...
Ripl.start

```

There is a comprehensive list of plugins for ripl as well as list of console applications using ripl on the projects website.