Skip to content

Commit a8a1020

Browse files
committed
Add --packaged option to "thor docs:list"
1 parent 1f6a679 commit a8a1020

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

lib/tasks/docs.thor

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,26 @@ class DocsCLI < Thor
1212
end
1313

1414
desc 'list', 'List available documentations'
15+
option :packaged, type: :boolean
1516
def list
16-
output = Docs.all.flat_map do |doc|
17-
name = doc.to_s.demodulize.underscore
18-
if doc.versioned?
19-
doc.versions.map { |_doc| "#{name}@#{_doc.version}" }
20-
else
21-
name
17+
if options[:packaged]
18+
names = Dir[File.join(Docs.store_path, '*.tar.gz')].map { |f| File.basename(f, '.tar.gz') }
19+
puts names
20+
else
21+
names = Docs.all.flat_map do |doc|
22+
name = doc.to_s.demodulize.underscore
23+
if doc.versioned?
24+
doc.versions.map { |_doc| "#{name}@#{_doc.version}" }
25+
else
26+
name
27+
end
2228
end
23-
end.join("\n")
2429

25-
require 'tty-pager'
26-
TTY::Pager.new.page(output)
30+
output = names.join("\n")
31+
32+
require 'tty-pager'
33+
TTY::Pager.new.page(output)
34+
end
2735
end
2836

2937
desc 'page <doc> [path] [--version] [--verbose] [--debug]', 'Generate a page (no indexing)'

0 commit comments

Comments
 (0)