Generate file name if given output path CLI argument is a directory

Closes #67
This commit is contained in:
Alexey Golub
2018-08-13 23:25:06 +03:00
parent bd9dc6455f
commit 614bd8590d
2 changed files with 8 additions and 2 deletions

View File

@@ -38,9 +38,9 @@ namespace DiscordChatExporter.Cli.Verbs
// Generate file path if not set
var filePath = Options.FilePath;
if (filePath.IsBlank())
if (filePath == null || filePath.EndsWith("/") || filePath.EndsWith("\\"))
{
filePath = $"{guild.Name} - {channel.Name}.{Options.ExportFormat.GetFileExtension()}"
filePath += $"{guild.Name} - {channel.Name}.{Options.ExportFormat.GetFileExtension()}"
.Replace(Path.GetInvalidFileNameChars(), '_');
}