mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-06-03 16:18:53 -04:00
Generate file name if given output path CLI argument is a directory
Closes #67
This commit is contained in:
parent
bd9dc6455f
commit
614bd8590d
2 changed files with 8 additions and 2 deletions
|
@ -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))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue