Class: EasyCaddy::Commands::List
- Inherits:
-
Object
- Object
- EasyCaddy::Commands::List
- Defined in:
- lib/easy_caddy/commands/list.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(format: 'table') ⇒ List
constructor
A new instance of List.
Constructor Details
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/easy_caddy/commands/list.rb', line 15 def call sites = @registry.all if sites.empty? puts ' No sites registered. Use `ecaddy run --config ./Caddyfile --site NAME` to add one.' return end if @format == 'json' require 'json' puts JSON.generate(sites.map { |s| row_data(s) }) return end require 'tty-table' rows = sites.map { |s| row_data(s).values } table = TTY::Table.new( header: ['Name', 'Status', 'Domains', 'Ports', 'Source'], rows: rows ) puts table.render(:unicode, padding: [0, 1]) end |