All Projects → tbpgr → Kosi

tbpgr / Kosi

Licence: mit
ターミナルアプリケーション用表フォーマットサポートツール。格子。

Programming Languages

ruby
36898 projects - #4 most used programming language

Labels

Projects that are alternatives of or similar to Kosi

Gowsdl
WSDL2Go code generation as well as its SOAP proxy
Stars: ✭ 844 (+6933.33%)
Mutual labels:  cli
Diskonaut
Terminal disk space navigator 🔭
Stars: ✭ 856 (+7033.33%)
Mutual labels:  cli
Fly
Deploy app servers close to your users. Package your app as a Docker image, and launch it in 17 cities with one simple CLI.
Stars: ✭ 862 (+7083.33%)
Mutual labels:  cli
Auto Cpufreq
Automatic CPU speed & power optimizer for Linux
Stars: ✭ 843 (+6925%)
Mutual labels:  cli
Suoxie
🔍 Query abbreviations in your command line or Node.js Api. 「查单词缩写」
Stars: ✭ 9 (-25%)
Mutual labels:  cli
Arf Converter
Bulk ARF file converter
Stars: ✭ 10 (-16.67%)
Mutual labels:  cli
Atom Check Updates
A CLI for easily updating Atom to the latest version on RPM or Debian-based systems.
Stars: ✭ 8 (-33.33%)
Mutual labels:  cli
Creater
create file with config
Stars: ✭ 12 (+0%)
Mutual labels:  cli
Get File
CLI and API to get a single file from Github repository.
Stars: ✭ 9 (-25%)
Mutual labels:  cli
Tabulate
Table Maker for Modern C++
Stars: ✭ 862 (+7083.33%)
Mutual labels:  cli
Serve
Static file serving and directory listing
Stars: ✭ 7,444 (+61933.33%)
Mutual labels:  cli
Sit Up
🙇 Reminder to sit up straight.
Stars: ✭ 9 (-25%)
Mutual labels:  cli
Tui Consolelauncher
Linux CLI Launcher for Android
Stars: ✭ 861 (+7075%)
Mutual labels:  cli
Lol Replay Downloader Cli
League of Legend replay CLI downloader (and decoder) without any software. Replays are saved into the cloud.
Stars: ✭ 8 (-33.33%)
Mutual labels:  cli
Gita
Manage many git repos with sanity 从容管理多个git库
Stars: ✭ 865 (+7108.33%)
Mutual labels:  cli
Ws50 Sync
ws50-sync is a python based program which pulls air quality data from your Withings account and stores it directly in a Domoticz DB.
Stars: ✭ 8 (-33.33%)
Mutual labels:  cli
Captain
command line python scripts for humans
Stars: ✭ 10 (-16.67%)
Mutual labels:  cli
Qsctl
Advanced command line tool for QingStor.
Stars: ✭ 12 (+0%)
Mutual labels:  cli
Ddecmd
DDE command line query tool
Stars: ✭ 11 (-8.33%)
Mutual labels:  cli
Tty Which
Cross-platform implementation of Unix `which` command
Stars: ✭ 11 (-8.33%)
Mutual labels:  cli

Kosi

Gem Version Gem Downloads Build Status Coverage Status Code Climate

ターミナルアプリケーション用表フォーマットサポートツール。格子。

🎶 Images

🐤 Before

,👽,👵👵
👴,🐶,👶👶👶👶👶👶👶
🐱🐱,,🐙🐙🐙🐙🐙

🐔 After

+----------+--------------------------+--------------------------+
||👽❔❔❔❔❔❔|👵👵❔❔❔❔❔|
|👴❔❔|🐶❔❔❔❔❔❔|👶👶👶👶👶👶👶|
|🐱🐱❔||🐙🐙🐙🐙🐙❔❔|
+----------+--------------------------+--------------------------+

☁️⬇️ Installation

Add this line to your application's Gemfile:

gem 'kosi'

And then execute:

$ bundle

Or install it yourself as:

$ gem install kosi

👨 Description

2次元配列をテーブルフォーマットにして出力します。
🔗 terminal-table gem の日本語対応版にあたります。
(terminal-tableはASCII対応のみなので全角文字が混ざるとテーブルレイアウトが崩れる)

🅾️ Options

🍦 Align

配置指定。右寄せ、左寄せ、中央を選択可能。

設定可能パラメータ 説明
Kosi::Align::TYPE::RIGHT 右寄せ
Kosi::Align::TYPE::LEFT 左寄せ。デフォルト
Kosi::Align::TYPE::CENTER 中央

🍦 ConnectorChar

表の結合部に表示するテキスト。1文字で指定。
下記で言うところの 「+」がConnectorChar。

+-----+------+-------+
|a    |b     |c      |
+-----+------+-------+

🍦 Header

表のヘッダー。配列で指定。
デフォルトはヘッダーなし。

🍦 HorizontalBorderChar

水平線を1文字で設定。
デフォルトは「-」(半角ハイフン)

🍦 SeparateEachRow

各行に区切り線を入れるかどうか。
デフォルトは「false」

🍦 VerticalBorderChar

垂直線を1文字で設定。
デフォルトは「|」(パイプ)

📜 Usage

🍧 オプション指定なし

require 'kosi'

kosi = Kosi::Table.new
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333']])
  • 出力
    ※GitHubの表示上ずれているかもしれませんが、等幅フォント利用時にそろいます。
+-----+------+-------+
|a    |b     |c      |
|ほゲ1|ひゲ22|へゲ333|
+-----+------+-------+

🍧 Align指定

require 'kosi'

kosi = Kosi::Table.new({align: Kosi::Align::TYPE::CENTER})
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333']])
kosi = Kosi::Table.new({align: Kosi::Align::TYPE::RIGHT})
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333']])
kosi = Kosi::Table.new({align: Kosi::Align::TYPE::LEFT})
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333']])
  • 出力
+-----+------+-------+
|  a  |  b   |   c   |
|ほゲ1|ひゲ22|へゲ333|
+-----+------+-------+
+-----+------+-------+
|    a|     b|      c|
|ほゲ1|ひゲ22|へゲ333|
+-----+------+-------+
+-----+------+-------+
|a    |b     |c      |
|ほゲ1|ひゲ22|へゲ333|
+-----+------+-------+

🍧 ConnectorChar指定

require 'kosi'

kosi = Kosi::Table.new
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333']])
kosi = Kosi::Table.new({connector_char: 'x'})
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333']])
kosi = Kosi::Table.new({connector_char: '$'})
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333']])
  • 出力
+-----+------+-------+
|a    |b     |c      |
|ほゲ1|ひゲ22|へゲ333|
+-----+------+-------+
x-----x------x-------x
|a    |b     |c      |
|ほゲ1|ひゲ22|へゲ333|
x-----x------x-------x
$-----$------$-------$
|a    |b     |c      |
|ほゲ1|ひゲ22|へゲ333|
$-----$------$-------$

🍧 Header指定

require 'kosi'

kosi = Kosi::Table.new
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333']])
kosi = Kosi::Table.new({header: %w{column1 column2 column3}})
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333']])
  • 出力
+-----+------+-------+
|a    |b     |c      |
|ほゲ1|ひゲ22|へゲ333|
+-----+------+-------+
+-------+-------+-------+
|column1|column2|column3|
+-------+-------+-------+
|a      |b      |c      |
|ほゲ1  |ひゲ22 |へゲ333|
+-------+-------+-------+

🍧 HorizontalBorderChar指定

require 'kosi'

kosi = Kosi::Table.new
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333']])
kosi = Kosi::Table.new({horizontal_border_char: '*'})
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333']])
  • 出力
+-----+------+-------+
|a    |b     |c      |
|ほゲ1|ひゲ22|へゲ333|
+-----+------+-------+
+*****+******+*******+
|a    |b     |c      |
|ほゲ1|ひゲ22|へゲ333|
+*****+******+*******+

🍧 SeparateEachRow指定

require 'kosi'

kosi = Kosi::Table.new
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333'], [*'a'..'c']])
kosi = Kosi::Table.new({separate_each_row: true})
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333'], [*'a'..'c']])
  • 出力
+-----+------+-------+
|a    |b     |c      |
|ほゲ1|ひゲ22|へゲ333|
|a    |b     |c      |
+-----+------+-------+
+-----+------+-------+
|a    |b     |c      |
+-----+------+-------+
|ほゲ1|ひゲ22|へゲ333|
+-----+------+-------+
|a    |b     |c      |
+-----+------+-------+

🍧 VerticalBorderChar指定

require 'kosi'

kosi = Kosi::Table.new
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333']])
kosi = Kosi::Table.new({vertical_border_char: '#'})
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333']])
  • 出力
+-----+------+-------+
|a    |b     |c      |
|ほゲ1|ひゲ22|へゲ333|
+-----+------+-------+
+-----+------+-------+
#a    #b     #c      #
#ほゲ1#ひゲ22#へゲ333#
+-----+------+-------+

🍧 複合オプション

様々なオプションを一気に指定してみます

require 'kosi'

kosi = Kosi::Table.new(
    {
      align: Kosi::Align::TYPE::CENTER,
      connector_char: 'x',
      header: %w{column1 column2 column3},
      horizontal_border_char: '*',
      vertical_border_char: '#',
      separate_each_row: true
    }
  )
print kosi.render([[*'a'..'c'], ['ほゲ1', 'ひゲ22', 'へゲ333'], [*'a'..'c']])
  • 出力
x*******x*******x*******x
#column1#column2#column3#
x*******x*******x*******x
#   a   #   b   #   c   #
x*******x*******x*******x
# ほゲ1 #ひゲ22 #へゲ333#
x*******x*******x*******x
#   a   #   b   #   c   #
x*******x*******x*******x

👬 Contributing 👭

  1. Fork it ( https://github.com/tbpgr/kosi/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].