mirror of https://github.com/getmango/Mango.git
Use tallboy to draw CLI table
This commit is contained in:
parent
af2fd2a66a
commit
5685dd1cc5
|
@ -68,3 +68,7 @@ shards:
|
||||||
git: https://github.com/crystal-lang/crystal-sqlite3.git
|
git: https://github.com/crystal-lang/crystal-sqlite3.git
|
||||||
version: 0.16.0
|
version: 0.16.0
|
||||||
|
|
||||||
|
tallboy:
|
||||||
|
git: https://github.com/epoch/tallboy.git
|
||||||
|
version: 0.9.3
|
||||||
|
|
||||||
|
|
|
@ -39,3 +39,5 @@ dependencies:
|
||||||
github: hkalexling/image_size.cr
|
github: hkalexling/image_size.cr
|
||||||
koa:
|
koa:
|
||||||
github: hkalexling/koa
|
github: hkalexling/koa
|
||||||
|
tallboy:
|
||||||
|
github: epoch/tallboy
|
||||||
|
|
18
src/mango.cr
18
src/mango.cr
|
@ -3,9 +3,10 @@ require "./queue"
|
||||||
require "./server"
|
require "./server"
|
||||||
require "./main_fiber"
|
require "./main_fiber"
|
||||||
require "./mangadex/*"
|
require "./mangadex/*"
|
||||||
|
require "./plugin/*"
|
||||||
require "option_parser"
|
require "option_parser"
|
||||||
require "clim"
|
require "clim"
|
||||||
require "./plugin/*"
|
require "tallboy"
|
||||||
|
|
||||||
MANGO_VERSION = "0.17.1"
|
MANGO_VERSION = "0.17.1"
|
||||||
|
|
||||||
|
@ -110,18 +111,13 @@ class CLI < Clim
|
||||||
password.not_nil!, opts.admin
|
password.not_nil!, opts.admin
|
||||||
when "list"
|
when "list"
|
||||||
users = storage.list_users
|
users = storage.list_users
|
||||||
name_length = users.map(&.[0].size).max? || 0
|
table = Tallboy.table do
|
||||||
l_cell_width = ["username".size, name_length].max
|
header ["username", "admin access"]
|
||||||
r_cell_width = "admin access".size
|
|
||||||
header = " #{"username".ljust l_cell_width} | admin access "
|
|
||||||
puts "-" * header.size
|
|
||||||
puts header
|
|
||||||
puts "-" * header.size
|
|
||||||
users.each do |name, admin|
|
users.each do |name, admin|
|
||||||
puts " #{name.ljust l_cell_width} | " \
|
row [name, admin]
|
||||||
"#{admin.to_s.ljust r_cell_width} "
|
|
||||||
end
|
end
|
||||||
puts "-" * header.size
|
end
|
||||||
|
puts table
|
||||||
when nil
|
when nil
|
||||||
puts opts.help_string
|
puts opts.help_string
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue