Take filename to write to as optional parameter to export_category

My discourse instance will be making regular automated public backups
of specific categories. It's preferred to be able to directly control
the path and filename of the output, rather than letting discourse
choose for me. This was already mostly supported, a filename parameter
just needed to be passed through the cli app.
This commit is contained in:
Erik Bernhardson 2016-02-12 22:02:24 -08:00
parent 3939b9ec7d
commit 48cb386d58
2 changed files with 4 additions and 4 deletions

View file

@ -6,8 +6,8 @@ require "json"
module ImportExport module ImportExport
def self.export_category(category_id) def self.export_category(category_id, filename=nil)
ImportExport::CategoryExporter.new(category_id).perform.save_to_file ImportExport::CategoryExporter.new(category_id).perform.save_to_file(filename)
end end
def self.import_category(filename) def self.import_category(filename)

View file

@ -135,12 +135,12 @@ class DiscourseCLI < Thor
end end
desc "export_category", "Export a category, all its topics, and all users who posted in those topics" desc "export_category", "Export a category, all its topics, and all users who posted in those topics"
def export_category(category_id) def export_category(category_id, filename=nil)
raise "Category id argument is missing!" unless category_id raise "Category id argument is missing!" unless category_id
load_rails load_rails
load_import_export load_import_export
ImportExport.export_category(category_id) ImportExport.export_category(category_id, filename)
puts "", "Done", "" puts "", "Done", ""
end end