1
0
mirror of https://github.com/bitwarden/help synced 2025-12-16 00:03:41 +00:00
Files
help/vendor/bundle/ruby/2.6.0/gems/terminal-table-2.0.0
fred_the_tech_writer 906e2ca0dd Promote to Master (#748)
* initial commit

* adding quotes for the array error

* Create Gemfile

* Create Gemfile.lock

* add .nvmrc and .node-version

* removed /article from URL

* update links to work with netlify

* more fixed links

* link fixes

* update bad links

* Update netlify.toml

toml test for redirects

* article redirect

* link fixes

* Update index.html

* Update netlify.toml

* Update _config.yml

* Update netlify.toml

* Update netlify.toml

* Update netlify.toml

* Update netlify.toml

* Update netlify.toml

* add article back into URL for launch

* Update netlify.toml

* Update netlify.toml

* add order to categories front matter

* Update netlify.toml

* update

* sidemenu update

* Revert "sidemenu update"

This reverts commit 5441c3d35c.

* update order prop

* Navbar updates per Gary and compiler warnings

* font/style tweaks

* Update sidebar.html

* Stage Release Documentation (#739)

* initial drafts

* rewrite Custom Fields article to prioritize new context-menu option & better organize ancillary information

* edit

* edit

* Custom Field Context Menu & CAPTCHA item in release notes

* SSO relink event

* update rn

* small edits

* improve release notes titles

* fix side menu

* Edits courtest of mportune!

* update order

* link fixes

* link cleanup

* image updates and a link

* fix trailing slash

Co-authored-by: DanHillesheim <79476558+DanHillesheim@users.noreply.github.com>
2021-09-21 13:21:11 -04:00
..
2021-09-21 13:21:11 -04:00
2021-09-21 13:21:11 -04:00
2021-09-21 13:21:11 -04:00
2021-09-21 13:21:11 -04:00
2021-09-21 13:21:11 -04:00
2021-09-21 13:21:11 -04:00
2021-09-21 13:21:11 -04:00
2021-09-21 13:21:11 -04:00
2021-09-21 13:21:11 -04:00
2021-09-21 13:21:11 -04:00
2021-09-21 13:21:11 -04:00

{<img src="https://github.com/tj/terminal-table/workflows/CI/badge.svg" />}[https://github.com/tj/terminal-table/actions]

= Terminal Table

== Description

Terminal Table is a fast and simple, yet feature rich ASCII table generator written in Ruby.

== Installation

  $ gem install terminal-table

== Usage

=== Basics

To use Terminal Table:

  require 'terminal-table'

To generate a table, provide an array of arrays (which are interpreted as rows):

  rows = []
  rows << ['One', 1]
  rows << ['Two', 2]
  rows << ['Three', 3]
  table = Terminal::Table.new :rows => rows

  # > puts table
  #
  # +-------+---+
  # | One   | 1 |
  # | Two   | 2 |
  # | Three | 3 |
  # +-------+---+


The constructor can also be given a block which is either yielded the Table object or instance evaluated:

  table = Terminal::Table.new do |t|
    t.rows = rows
  end

  table = Terminal::Table.new do
    self.rows = rows
  end

Adding rows one by one:

  table = Terminal::Table.new do |t|
    t << ['One', 1]
    t.add_row ['Two', 2]
  end

To add separators between rows:

  table = Terminal::Table.new do |t|
    t << ['One', 1]
    t << :separator
    t.add_row ['Two', 2]
    t.add_separator
    t.add_row ['Three', 3]
  end

  # > puts table
  #
  # +-------+---+
  # | One   | 1 |
  # +-------+---+
  # | Two   | 2 |
  # +-------+---+
  # | Three | 3 |
  # +-------+---+

Cells can handle multiline content:

  table = Terminal::Table.new do |t|
    t << ['One', 1]
    t << :separator
    t.add_row ["Two\nDouble", 2]
    t.add_separator
    t.add_row ['Three', 3]
  end

  # > puts table
  #
  # +--------+---+
  # | One    | 1 |
  # +--------+---+
  # | Two    | 2 |
  # | Double |   |
  # +--------+---+
  # | Three  | 3 |
  # +--------+---+

=== Head

To add a head to the table:

  table = Terminal::Table.new :headings => ['Word', 'Number'], :rows => rows

  # > puts table
  #
  # +-------+--------+
  # | Word  | Number |
  # +-------+--------+
  # | One   | 1      |
  # | Two   | 2      |
  # | Three | 3      |
  # +-------+--------+

=== Title

To add a title to the table:

  table = Terminal::Table.new :title => "Cheatsheet", :headings => ['Word', 'Number'], :rows => rows

  # > puts table
  #
  # +------------+--------+
  # |     Cheatsheet      |
  # +------------+--------+
  # | Word       | Number |
  # +------------+--------+
  # | One        | 1      |
  # | Two        | 2      |
  # | Three      | 3      |
  # +------------+--------+

=== Alignment

To align the second column to the right:

  table.align_column(1, :right)

  # > puts table
  #
  # +-------+--------+
  # | Word  | Number |
  # +-------+--------+
  # | One   |      1 |
  # | Two   |      2 |
  # | Three |      3 |
  # +-------+--------+

To align an individual cell, you specify the cell value in a hash along the alignment:

  table << ["Four", {:value => 4.0, :alignment => :center}]

  # > puts table
  #
  # +-------+--------+
  # | Word  | Number |
  # +-------+--------+
  # | One   |      1 |
  # | Two   |      2 |
  # | Three |      3 |
  # | Four  |  4.0   |
  # +-------+--------+

=== Style

To specify style options:

  table = Terminal::Table.new :headings => ['Word', 'Number'], :rows => rows, :style => {:width => 80}

  # > puts table
  #
  # +--------------------------------------+---------------------------------------+
  # | Word                                 | Number                                |
  # +--------------------------------------+---------------------------------------+
  # | One                                  | 1                                     |
  # | Two                                  | 2                                     |
  # | Three                                | 3                                     |
  # +--------------------------------------+---------------------------------------+

And change styles on the fly:

  table.style = {:width => 40, :padding_left => 3, :border_x => "=", :border_i => "x"}

  # > puts table
  #
  # x====================x=================x
  # |               Cheatsheet             |
  # x====================x=================x
  # |   Word             |   Number        |
  # x====================x=================x
  # |   One              |   1             |
  # |   Two              |   2             |
  # |   Three            |   3             |
  # x====================x=================x

You can also use styles to add a separator after every row:

  table = Terminal::Table.new do |t|
    t.add_row [1, 'One']
    t.add_row [2, 'Two']
    t.add_row [3, 'Three']
    t.style = {:all_separators => true}
  end

  # > puts table
  #
  # +---+-------+
  # | 1 | One   |
  # +---+-------+
  # | 2 | Two   |
  # +---+-------+
  # | 3 | Three |
  # +---+-------+

You can also use styles to disable top and bottom borders of the table

  table = Terminal::Table.new do |t|
    t.headings = ['id', 'name']
    t.rows = [[1, 'One'], [2, 'Two'], [3, 'Three']]
    t.style = { :border_top => false, :border_bottom => false }
  end

  # > puts table
  # | id | name  |
  # +----+-------+
  # | 1  | One   |
  # | 2  | Two   |
  # | 3  | Three |

To change the default style options:

  Terminal::Table::Style.defaults = {:width => 80}

All Table objects created afterwards will inherit these defaults.

=== Constructor options and setter methods

Valid options for the constructor are :rows, :headings, :style and :title - and all options can also be set on the created table object by their setter method:

  table = Terminal::Table.new
  table.title = "Cheatsheet"
  table.headings = ['Word', 'Number']
  table.rows = rows
  table.style = {:width => 40}

== More examples

For more examples, please see the examples/examples.rb file included in the source distribution.

== Author

TJ Holowaychuk <tj@vision-media.ca>