From 48cb386d58d7e5b2d31b8377ff488271b05d4bf8 Mon Sep 17 00:00:00 2001 From: Erik Bernhardson Date: Fri, 12 Feb 2016 22:02:24 -0800 Subject: [PATCH] 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. --- lib/import_export/import_export.rb | 4 ++-- script/discourse | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/import_export/import_export.rb b/lib/import_export/import_export.rb index 715a4bea5..4bb6fa925 100644 --- a/lib/import_export/import_export.rb +++ b/lib/import_export/import_export.rb @@ -6,8 +6,8 @@ require "json" module ImportExport - def self.export_category(category_id) - ImportExport::CategoryExporter.new(category_id).perform.save_to_file + def self.export_category(category_id, filename=nil) + ImportExport::CategoryExporter.new(category_id).perform.save_to_file(filename) end def self.import_category(filename) diff --git a/script/discourse b/script/discourse index fb91f986f..af03de89b 100755 --- a/script/discourse +++ b/script/discourse @@ -135,12 +135,12 @@ class DiscourseCLI < Thor end 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 load_rails load_import_export - ImportExport.export_category(category_id) + ImportExport.export_category(category_id, filename) puts "", "Done", "" end