Giter VIP home page Giter VIP logo

menutree's Introduction

Menutree

Menutree is a framework for presenting a recursive Read-Eval-Print Loop (REPL) shell on the command line, inspired by the CLI found in Cisco IOS and other similar products. Menutree lets users issue commands via an interactive nested shell interface, and also directly from the command line.

The menu structure and commands therein are defined by a directory of ruby scripts conforming to a simple interface. Inline help, command completion, and readline support are all built in.

Example:

$ ./examples/example.rb
> action_one a b c 
This is action one, called with: a b c
> submenu_one
submenu_one> action_one
This is action one in submenu one, called with: 
submenu_one> ..
> submenu_two
submenu_two> action_one
This is action one in submenu two, called with: 
submenu_two> quit

Commands could also be run from the shell:

$ ./examples/example.rb submenu_one action_two a b c
This is action two in submenu one, called with: a b c

To implement this, one would provide Menutree with a directory that looked like:

commands/
  leaf.rb
  submenu_one/
    leaf.rb
  submenu_two/
    leaf.rb

Commands are defined inside a leaf.rb file in each directory, which adheres to a minimal DSL like so:

leaf do |tree|
  desc "This is action one's help"
  def action_one(*args)
    puts "This is action one, called with: #{args.join ' '}"
  end

  desc "This is action two's help"
  def action_two(*args)
    puts "This is action two, called with: #{args.join ' '}"
  end
end

menutree's People

Contributors

mtrudel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.