Class: DiscourseCli::CLI
- Inherits:
-
Thor
- Object
- Thor
- DiscourseCli::CLI
- Defined in:
- lib/discourse_cli/cli.rb
Instance Method Summary collapse
Instance Method Details
#categories ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/discourse_cli/cli.rb', line 8 def categories client = DiscourseCli::Client.client categories = client.categories puts "The following #{categories.count.to_s} categories were found:" puts categories.each do |c| puts "#{c['id']} #{c['name']} #{c['slug']}" end end |
#topics(category_slug) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/discourse_cli/cli.rb', line 21 def topics(category_slug) client = DiscourseCli::Client.client count = 30 page = 0 total = 0 results = {} while count == 30 do topics = client.category_latest_topics(category_slug: category_slug, page: page) count = topics.count topics.each do |t| results[t['id']] = t end page += 1 end puts "The following #{results.count} topics were found in the #{category_slug} category:" puts results.each do |k, v| puts "#{v['id']} #{v['title']}" end end |