Ergane & Potty

Active

A command-line framework and a terminal-UI framework for Ruby, built to work together.

Two libraries for tools that live in the terminal: Ergane for the command tree, Potty for everything drawn on screen.

Ergane defines a CLI as an Ergane::Tool whose commands are declared as blocks or as Command subclasses; both build the same tree. It generates help, typed options and flags, positional arguments whose required-ness comes from the run method’s own signature, arbitrarily nested subcommands, and shared-option base commands.

Potty builds terminal UIs from composable widgets (lists, forms, status bars, flash messages) with a view stack for navigation, a focus model, theming and tick-based animation. It renders full-screen through curses, or inline with ANSI output that stays in the normal terminal flow for spinners and ask/confirm/choose prompts.

Highlights

  • Arguments inferred from method signatures
  • Nested subcommands and shared options
  • Full-screen curses or inline ANSI rendering
  • Widgets, focus, theming and animation

In practice

Ergane
class MyCLI < Ergane::Tool
  tool_name :mycli
  version "1.0.0"

  command :greet do
    option :name, String, short: :n, default: "world"
    run { puts "Hello #{options[:name]}!" }
  end
end

MyCLI.start(ARGV)
Potty
class HelloView < Potty::View
  def build_layout
    @list = Potty::Widgets::List.new(app)
    @list.items = [Potty::Widgets::ActionItem.new('Quit') { app.quit }]
    @widgets = [@list]
    @list.focus
  end
end

app = Potty::Application.new
app.run(HelloView.new(app))

Looking for our apps?

upuppy and the rest of our commercial software, with support and contact, live at twilightcoders.com.