discourse_cli 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cccad6d284d25ec17b26630fb501c21e756fb4c7
4
- data.tar.gz: 8465bcbcc5cfb2d0e14f0eb4c93a04862b2c4f51
3
+ metadata.gz: 3834e48a5e76cb9ddea692f0818e4ac7e412f13c
4
+ data.tar.gz: 253fcf6671fa5b1794df2f58463e746e1f71c78d
5
5
  SHA512:
6
- metadata.gz: ecce878249cbd29c95d4e63c060e2c3bda026ce6714f4afa45333fa1efe3f83a1b408f9023d8ede52304de2710a56cbd57161b224df8c82c40d9f3db8c85c80f
7
- data.tar.gz: 8a38785d607faadc689efd9ee61237075f92a0a0d4129433b26c0d7a11098c20021ff5f67b88ccc2907b29ea8b9637023ffd7b9905dd860c2315086a19d28be8
6
+ metadata.gz: 5a6f9b125533c7fb1e86c3b59d410f3b191626b59388473af5bed06587d0c6d41fc79473e945549ba88834ee679ecf5f28bccfed1ee76b6644a7e641c7879809
7
+ data.tar.gz: ab5a8d40c2cb2c5f18968407260d702fe8a4c7f3ce7c8a25eaa75f9a838e7a0de80f38fb7c023c1a2db9f78e786ba04349b28336c3f69036af10b0e99bffd029
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Change Log
2
+ All notable changes to this project will be documented in this file.
3
+ This project adheres to [Semantic Versioning](http://semver.org/).
4
+
5
+ ## [0.2.0] - 2015-11-21
6
+ ### Added
7
+ - added `topics` command.
data/README.md CHANGED
@@ -24,13 +24,51 @@ but with settings for your own discourse instance:
24
24
 
25
25
  ## Usage
26
26
 
27
+ Type `discourse` to see a list of available commands:
28
+
29
+ $ discourse
30
+
31
+ Commands:
32
+ discourse categories # returns a list of categories
33
+ discourse help [COMMAND] # Describe available commands or one specific command
34
+ discourse topics CATEGORY_SLUG # returns a list of all the topics in the specified category
35
+
36
+ To see a list of categories:
37
+
27
38
  $ discourse categories
39
+
40
+ The following 6 categories were found:
41
+
42
+ 4 Staff staff
43
+ 1 Uncategorized uncategorized
44
+ 2 Lounge lounge
45
+ 3 Site Feedback site-feedback
46
+ 5 Parent Category2 parent-category
47
+ 7 test_category test-category
48
+
49
+
50
+ To see a list of topics in a category:
51
+
52
+ $ discourse topics test-category | head
53
+
54
+ The following 203 topics were found in the test-category category:
55
+
56
+ 220 Ruvxqzlajycmikwbfspndgheto
57
+ 219 Vgsdeloyuzbmpixqrtwjhfckna
58
+ 218 Fujohcvsnqptbaerwdzxgmlyki
59
+ 217 Yreaikwflptouscvjbxdqmghzn
60
+ 216 Jmytihfaervoklpsudngczbxwq
61
+ 215 Ylnkbcmujrqvdosfitpxzeaghw
62
+ 214 Rzageqphtbcnsfmxudlwiokjvy
63
+ 213 Afngbetiqovyxjpwklsczhdrmu
64
+
65
+
66
+ More commands coming soon!
28
67
 
29
68
 
30
69
  ## Contributing
31
70
 
32
- Bug reports and pull requests are welcome on GitHub at
33
- https://github.com/oblakeerickson/discourse_cli. This project is intended to be
71
+ Bug reports and pull requests are welcome. This project is intended to be
34
72
  a safe, welcoming space for collaboration, and contributors are expected to
35
73
  adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
36
74
 
@@ -3,15 +3,41 @@ require 'discourse_api'
3
3
 
4
4
  module DiscourseCli
5
5
  class CLI < Thor
6
-
6
+
7
7
  desc "categories", "returns a list of categories"
8
8
  def categories
9
9
  client = DiscourseCli::Client.client
10
10
  categories = client.categories
11
11
 
12
- puts "The following " + categories.count.to_s + " categories were found:"
12
+ puts "The following #{categories.count.to_s} categories were found:"
13
+ puts
14
+
13
15
  categories.each do |c|
14
- puts c['name']
16
+ puts "#{c['id']} #{c['name']} #{c['slug']}"
17
+ end
18
+ end
19
+
20
+ desc "topics CATEGORY_SLUG", "returns a list of all the topics in the specified category"
21
+ def topics(category_slug)
22
+ client = DiscourseCli::Client.client
23
+ count = 30
24
+ page = 0
25
+ total = 0
26
+ results = {}
27
+ while count == 30 do
28
+ topics = client.category_latest_topics(category_slug: category_slug, page: page)
29
+ count = topics.count
30
+ topics.each do |t|
31
+ results[t['id']] = t
32
+ end
33
+ page += 1
34
+ end
35
+
36
+ puts "The following #{results.count} topics were found in the #{category_slug} category:"
37
+ puts
38
+
39
+ results.each do |k, v|
40
+ puts "#{v['id']} #{v['title']}"
15
41
  end
16
42
  end
17
43
  end
@@ -6,7 +6,6 @@ module DiscourseCli
6
6
  def self.client
7
7
  secrets_file = ENV['HOME'] + '/.discourse_cli'
8
8
  secrets = YAML.load_file secrets_file
9
-
10
9
  client = DiscourseApi::Client.new(secrets['discourse']['host'])
11
10
  client.api_key = secrets['discourse']['api_key']
12
11
  client.api_username = secrets['discourse']['api_username']
@@ -1,3 +1,3 @@
1
1
  module DiscourseCli
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discourse_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Erickson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-19 00:00:00.000000000 Z
11
+ date: 2015-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -98,6 +98,7 @@ extra_rdoc_files: []
98
98
  files:
99
99
  - ".gitignore"
100
100
  - ".travis.yml"
101
+ - CHANGELOG.md
101
102
  - CODE_OF_CONDUCT.md
102
103
  - Gemfile
103
104
  - LICENSE