Class: DiscourseCli::Commands::Categories
- Defined in:
- lib/discourse_cli/commands/categories.rb
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#create ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/discourse_cli/commands/categories.rb', line 25 def create params = { name: [:name] } params[:color] = [:color] if [:color] params[:text_color] = [:"text-color"] if [:"text-color"] params[:description] = [:description] if [:description] formatter.print_item(client.create_category(params)) rescue DiscourseApi::DiscourseError => e handle_error(e) end |
#delete(id) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/discourse_cli/commands/categories.rb', line 53 def delete(id) client.delete_category(id.to_i) formatter.print_success("Deleted category #{id}") rescue DiscourseApi::DiscourseError => e handle_error(e) end |
#list ⇒ Object
7 8 9 10 11 |
# File 'lib/discourse_cli/commands/categories.rb', line 7 def list formatter.print_list(client.categories) rescue DiscourseApi::DiscourseError => e handle_error(e) end |
#show(id) ⇒ Object
14 15 16 17 18 |
# File 'lib/discourse_cli/commands/categories.rb', line 14 def show(id) formatter.print_item(client.category(id.to_i)) rescue DiscourseApi::DiscourseError => e handle_error(e) end |
#update(id) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/discourse_cli/commands/categories.rb', line 40 def update(id) params = { id: id.to_i, name: [:name] } params[:color] = [:color] if [:color] params[:text_color] = [:"text-color"] if [:"text-color"] params[:description] = [:description] if [:description] result = client.update_category(params) formatter.print_item(result) if result formatter.print_success("Updated category #{id}") rescue DiscourseApi::DiscourseError => e handle_error(e) end |