History

Add --packaged option to "thor docs:list"

Thibaut Courouble committed 7 years ago

Commit a8a10201 parent 1f6a6791 file · +17 −9Browse files

Unified · Split

lib/tasks/docs.thor+17−9
@@ -12,18 +12,26 @@ class DocsCLI < Thor · 11 unmodified lines
12 end12 end
13 13
14 desc 'list', 'List available documentations'14 desc 'list', 'List available documentations'
15 option :packaged, type: :boolean
15 def list16 def list
16 output = Docs.all.flat_map do |doc|17 if options[:packaged]
17 name = doc.to_s.demodulize.underscore18 names = Dir[File.join(Docs.store_path, '*.tar.gz')].map { |f| File.basename(f, '.tar.gz') }
18 if doc.versioned?19 puts names
19 doc.versions.map { |_doc| "#{name}@#{_doc.version}" }20 else
20 else21 names = Docs.all.flat_map do |doc|
21 name22 name = doc.to_s.demodulize.underscore
23 if doc.versioned?
24 doc.versions.map { |_doc| "#{name}@#{_doc.version}" }
25 else
26 name
27 end
22 end28 end
23 end.join("\n")
24 29
25 require 'tty-pager'30 output = names.join("\n")
26 TTY::Pager.new.page(output)31
32 require 'tty-pager'
33 TTY::Pager.new.page(output)
34 end
27 end35 end
28 36
29 desc 'page <doc> [path] [--version] [--verbose] [--debug]', 'Generate a page (no indexing)'37 desc 'page <doc> [path] [--version] [--verbose] [--debug]', 'Generate a page (no indexing)'