mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
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:
parent
3939b9ec7d
commit
48cb386d58
2 changed files with 4 additions and 4 deletions
|
@ -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)
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue