term_utils

Terminal utilities for Ruby.

Purpose

Provides terminal utilities like table formatting.

Content

Table formatting

Take the following table:

    id  string8   string16        
  ----  --------  ----------------
     1  Fiat Lux  Fiat Lux        
     2  Alea ...  Alea jacta est  
     3  Audac...  Audaces fortuna juvat
  ----  --------  ----------------
    id  string8   string16

You can produce it with the following code:

require 'term_utils/tab'

TermUtils::Tab.define_table(:foo) do |t|
  t.define_column :id, :width => 4, :align => :right
  t.define_column :string8, :fixed => true, :ellipsis => "..."
  t.define_column :string16, :width => 16
end

data = []
data << [1, "Fiat Lux", "Fiat Lux"]
data << [2, "Alea jacta est", "Alea jacta est"]
data << [3, "Audaces fortuna juvat", "Audaces fortuna juvat"]

TermUtils::Tab.printer :foo, $stdout, :offset => 2 do |tpr|
  tpr.line
  tpr.header
  tpr.separator
  data.each do |d|
    tpr.data d
  end
  tpr.separator
  tpr.header
  tpr.line
end

Argument Parsing

The Argument Parsing module provides a way to parse command line arguments.

See Samples.

File Finder

The File Finder module provides a way to query the filesystem.

See the samples.

License

GPL-3.0-only.