mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-23 03:06:53 -04:00
[CLI] Print error and exit if reuse-media option is used without media option (#433)
This commit is contained in:
parent
37fcee2f21
commit
53cebd82eb
2 changed files with 13 additions and 1 deletions
|
@ -3,6 +3,7 @@ using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using CliFx;
|
using CliFx;
|
||||||
using CliFx.Attributes;
|
using CliFx.Attributes;
|
||||||
|
using CliFx.Exceptions;
|
||||||
using CliFx.Utilities;
|
using CliFx.Utilities;
|
||||||
using DiscordChatExporter.Domain.Discord.Models;
|
using DiscordChatExporter.Domain.Discord.Models;
|
||||||
using DiscordChatExporter.Domain.Exporting;
|
using DiscordChatExporter.Domain.Exporting;
|
||||||
|
@ -11,6 +12,7 @@ namespace DiscordChatExporter.Cli.Commands.Base
|
||||||
{
|
{
|
||||||
public abstract class ExportCommandBase : TokenCommandBase
|
public abstract class ExportCommandBase : TokenCommandBase
|
||||||
{
|
{
|
||||||
|
|
||||||
[CommandOption("output", 'o',
|
[CommandOption("output", 'o',
|
||||||
Description = "Output file or directory path.")]
|
Description = "Output file or directory path.")]
|
||||||
public string OutputPath { get; set; } = Directory.GetCurrentDirectory();
|
public string OutputPath { get; set; } = Directory.GetCurrentDirectory();
|
||||||
|
@ -69,6 +71,13 @@ namespace DiscordChatExporter.Cli.Commands.Base
|
||||||
console.Output.WriteLine("Done.");
|
console.Output.WriteLine("Done.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ExecuteAsync()
|
||||||
|
{
|
||||||
|
if (ShouldReuseMedia && !ShouldDownloadMedia)
|
||||||
|
{
|
||||||
|
throw new CommandException("The --reuse-media option cannot be used without the --media option.");
|
||||||
|
}
|
||||||
|
}
|
||||||
protected async ValueTask ExportAsync(IConsole console, Channel channel)
|
protected async ValueTask ExportAsync(IConsole console, Channel channel)
|
||||||
{
|
{
|
||||||
var guild = await GetDiscordClient().GetGuildAsync(channel.GuildId);
|
var guild = await GetDiscordClient().GetGuildAsync(channel.GuildId);
|
||||||
|
|
|
@ -12,7 +12,10 @@ namespace DiscordChatExporter.Cli.Commands
|
||||||
Description = "Channel ID.")]
|
Description = "Channel ID.")]
|
||||||
public string ChannelId { get; set; } = "";
|
public string ChannelId { get; set; } = "";
|
||||||
|
|
||||||
public override async ValueTask ExecuteAsync(IConsole console) =>
|
public override async ValueTask ExecuteAsync(IConsole console)
|
||||||
|
{
|
||||||
|
base.ExecuteAsync();
|
||||||
await ExportAsync(console, ChannelId);
|
await ExportAsync(console, ChannelId);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue