mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-03-18 04:41:28 +00:00
Generate file name if given output path CLI argument is a directory
Closes #67
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using DiscordChatExporter.Core.Models;
|
||||
using Scriban;
|
||||
using Scriban.Runtime;
|
||||
using Tyrrrz.Extensions;
|
||||
|
||||
namespace DiscordChatExporter.Core.Services
|
||||
{
|
||||
@@ -37,6 +38,11 @@ namespace DiscordChatExporter.Core.Services
|
||||
var templateModel = new TemplateModel(format, log, _settingsService.DateFormat);
|
||||
context.PushGlobal(templateModel.GetScriptObject());
|
||||
|
||||
// Create directory
|
||||
var dirPath = Path.GetDirectoryName(filePath);
|
||||
if (dirPath.IsNotBlank())
|
||||
Directory.CreateDirectory(dirPath);
|
||||
|
||||
// Render output
|
||||
using (var output = File.CreateText(filePath))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user