Skip to content

Instantly share code, notes, and snippets.

@emad-elsaid
Last active September 21, 2018 09:45
Show Gist options
  • Save emad-elsaid/b259894caa9a78863b582ecc7a31811a to your computer and use it in GitHub Desktop.
Save emad-elsaid/b259894caa9a78863b582ecc7a31811a to your computer and use it in GitHub Desktop.
this script uses 'command_tree' gem to define a tree of commands for the terminal
#!/usr/bin/env ruby
require 'command_tree'
t = CommandTree::Tree.new
# You register functions here to be executed with characters sequence
t.register('a', 'Greetings')
t.register('ag', 'Greeting') { puts 'hello' }
t.register('aG', 'Greeting special') { puts 'hello man.' } # character are case sensitive
t.register('as', 'Sup') { puts 'Sup man' }
t.register('g', 'Goodbyes')
t.register('gg', 'Salam') { puts "Salam man" }
t.register('gu', 'See you') { puts "See you tomorrow" }
t.show
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment