From a8a1020ddfb6213e51db3e05641d65b002f79ecc Mon Sep 17 00:00:00 2001 From: Thibaut Courouble Date: Sun, 25 Nov 2018 12:21:20 -0500 Subject: [PATCH] Add --packaged option to "thor docs:list" --- lib/tasks/docs.thor | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/lib/tasks/docs.thor b/lib/tasks/docs.thor index 59fdf9d4..2e8241d2 100644 --- a/lib/tasks/docs.thor +++ b/lib/tasks/docs.thor @@ -12,18 +12,26 @@ class DocsCLI < Thor end desc 'list', 'List available documentations' + option :packaged, type: :boolean def list - output = Docs.all.flat_map do |doc| - name = doc.to_s.demodulize.underscore - if doc.versioned? - doc.versions.map { |_doc| "#{name}@#{_doc.version}" } - else - name + if options[:packaged] + names = Dir[File.join(Docs.store_path, '*.tar.gz')].map { |f| File.basename(f, '.tar.gz') } + puts names + else + names = Docs.all.flat_map do |doc| + name = doc.to_s.demodulize.underscore + if doc.versioned? + doc.versions.map { |_doc| "#{name}@#{_doc.version}" } + else + name + end end - end.join("\n") - require 'tty-pager' - TTY::Pager.new.page(output) + output = names.join("\n") + + require 'tty-pager' + TTY::Pager.new.page(output) + end end desc 'page [path] [--version] [--verbose] [--debug]', 'Generate a page (no indexing)'