mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-24 03:36:52 -04:00
Make CLI attributes look tidier
This commit is contained in:
parent
65a528e7fe
commit
62400f305a
6 changed files with 78 additions and 16 deletions
|
@ -20,34 +20,67 @@ namespace DiscordChatExporter.Cli.Commands.Base;
|
||||||
|
|
||||||
public abstract class ExportCommandBase : TokenCommandBase
|
public abstract class ExportCommandBase : TokenCommandBase
|
||||||
{
|
{
|
||||||
[CommandOption("output", 'o', Description = "Output file or directory path.")]
|
[CommandOption(
|
||||||
|
"output",
|
||||||
|
'o',
|
||||||
|
Description = "Output file or directory path."
|
||||||
|
)]
|
||||||
public string OutputPath { get; init; } = Directory.GetCurrentDirectory();
|
public string OutputPath { get; init; } = Directory.GetCurrentDirectory();
|
||||||
|
|
||||||
[CommandOption("format", 'f', Description = "Export format.")]
|
[CommandOption(
|
||||||
|
"format",
|
||||||
|
'f',
|
||||||
|
Description = "Export format."
|
||||||
|
)]
|
||||||
public ExportFormat ExportFormat { get; init; } = ExportFormat.HtmlDark;
|
public ExportFormat ExportFormat { get; init; } = ExportFormat.HtmlDark;
|
||||||
|
|
||||||
[CommandOption("after", Description = "Only include messages sent after this date or message ID.")]
|
[CommandOption(
|
||||||
|
"after",
|
||||||
|
Description = "Only include messages sent after this date or message ID."
|
||||||
|
)]
|
||||||
public Snowflake? After { get; init; }
|
public Snowflake? After { get; init; }
|
||||||
|
|
||||||
[CommandOption("before", Description = "Only include messages sent before this date or message ID.")]
|
[CommandOption(
|
||||||
|
"before",
|
||||||
|
Description = "Only include messages sent before this date or message ID."
|
||||||
|
)]
|
||||||
public Snowflake? Before { get; init; }
|
public Snowflake? Before { get; init; }
|
||||||
|
|
||||||
[CommandOption("partition", 'p', Description = "Split output into partitions, each limited to this number of messages (e.g. '100') or file size (e.g. '10mb').")]
|
[CommandOption(
|
||||||
|
"partition",
|
||||||
|
'p',
|
||||||
|
Description = "Split output into partitions, each limited to this number of messages (e.g. '100') or file size (e.g. '10mb')."
|
||||||
|
)]
|
||||||
public PartitionLimit PartitionLimit { get; init; } = PartitionLimit.Null;
|
public PartitionLimit PartitionLimit { get; init; } = PartitionLimit.Null;
|
||||||
|
|
||||||
[CommandOption("filter", Description = "Only include messages that satisfy this filter (e.g. 'from:foo#1234' or 'has:image').")]
|
[CommandOption(
|
||||||
|
"filter",
|
||||||
|
Description = "Only include messages that satisfy this filter (e.g. 'from:foo#1234' or 'has:image')."
|
||||||
|
)]
|
||||||
public MessageFilter MessageFilter { get; init; } = MessageFilter.Null;
|
public MessageFilter MessageFilter { get; init; } = MessageFilter.Null;
|
||||||
|
|
||||||
[CommandOption("parallel", Description = "Limits how many channels can be exported in parallel.")]
|
[CommandOption(
|
||||||
|
"parallel",
|
||||||
|
Description = "Limits how many channels can be exported in parallel."
|
||||||
|
)]
|
||||||
public int ParallelLimit { get; init; } = 1;
|
public int ParallelLimit { get; init; } = 1;
|
||||||
|
|
||||||
[CommandOption("media", Description = "Download referenced media content.")]
|
[CommandOption(
|
||||||
|
"media",
|
||||||
|
Description = "Download referenced media content."
|
||||||
|
)]
|
||||||
public bool ShouldDownloadMedia { get; init; }
|
public bool ShouldDownloadMedia { get; init; }
|
||||||
|
|
||||||
[CommandOption("reuse-media", Description = "Reuse already existing media content to skip redundant downloads.")]
|
[CommandOption(
|
||||||
|
"reuse-media",
|
||||||
|
Description = "Reuse already existing media content to skip redundant downloads."
|
||||||
|
)]
|
||||||
public bool ShouldReuseMedia { get; init; }
|
public bool ShouldReuseMedia { get; init; }
|
||||||
|
|
||||||
[CommandOption("dateformat", Description = "Format used when writing dates.")]
|
[CommandOption(
|
||||||
|
"dateformat",
|
||||||
|
Description = "Format used when writing dates."
|
||||||
|
)]
|
||||||
public string DateFormat { get; init; } = "dd-MMM-yy hh:mm tt";
|
public string DateFormat { get; init; } = "dd-MMM-yy hh:mm tt";
|
||||||
|
|
||||||
private ChannelExporter? _channelExporter;
|
private ChannelExporter? _channelExporter;
|
||||||
|
|
|
@ -9,11 +9,22 @@ namespace DiscordChatExporter.Cli.Commands.Base;
|
||||||
|
|
||||||
public abstract class TokenCommandBase : ICommand
|
public abstract class TokenCommandBase : ICommand
|
||||||
{
|
{
|
||||||
[CommandOption("token", 't', IsRequired = true, EnvironmentVariable = "DISCORD_TOKEN", Description = "Authentication token.")]
|
[CommandOption(
|
||||||
|
"token",
|
||||||
|
't',
|
||||||
|
IsRequired = true,
|
||||||
|
EnvironmentVariable = "DISCORD_TOKEN",
|
||||||
|
Description = "Authentication token."
|
||||||
|
)]
|
||||||
public string Token { get; init; } = "";
|
public string Token { get; init; } = "";
|
||||||
|
|
||||||
[CommandOption("bot", 'b', EnvironmentVariable = "DISCORD_TOKEN_BOT", Description = "This option doesn't do anything. Kept for backwards compatibility.")]
|
|
||||||
[Obsolete("This option doesn't do anything. Kept for backwards compatibility.")]
|
[Obsolete("This option doesn't do anything. Kept for backwards compatibility.")]
|
||||||
|
[CommandOption(
|
||||||
|
"bot",
|
||||||
|
'b',
|
||||||
|
EnvironmentVariable = "DISCORD_TOKEN_BOT",
|
||||||
|
Description = "This option doesn't do anything. Kept for backwards compatibility."
|
||||||
|
)]
|
||||||
public bool IsBotToken { get; init; }
|
public bool IsBotToken { get; init; }
|
||||||
|
|
||||||
private DiscordClient? _discordClient;
|
private DiscordClient? _discordClient;
|
||||||
|
|
|
@ -10,7 +10,10 @@ namespace DiscordChatExporter.Cli.Commands;
|
||||||
[Command("exportall", Description = "Export all accessible channels.")]
|
[Command("exportall", Description = "Export all accessible channels.")]
|
||||||
public class ExportAllCommand : ExportCommandBase
|
public class ExportAllCommand : ExportCommandBase
|
||||||
{
|
{
|
||||||
[CommandOption("include-dm", Description = "Include direct message channels.")]
|
[CommandOption(
|
||||||
|
"include-dm",
|
||||||
|
Description = "Include direct message channels."
|
||||||
|
)]
|
||||||
public bool IncludeDirectMessages { get; init; } = true;
|
public bool IncludeDirectMessages { get; init; } = true;
|
||||||
|
|
||||||
public override async ValueTask ExecuteAsync(IConsole console)
|
public override async ValueTask ExecuteAsync(IConsole console)
|
||||||
|
|
|
@ -12,7 +12,12 @@ namespace DiscordChatExporter.Cli.Commands;
|
||||||
public class ExportChannelsCommand : ExportCommandBase
|
public class ExportChannelsCommand : ExportCommandBase
|
||||||
{
|
{
|
||||||
// TODO: change this to plural (breaking change)
|
// TODO: change this to plural (breaking change)
|
||||||
[CommandOption("channel", 'c', IsRequired = true, Description = "Channel ID(s).")]
|
[CommandOption(
|
||||||
|
"channel",
|
||||||
|
'c',
|
||||||
|
IsRequired = true,
|
||||||
|
Description = "Channel ID(s)."
|
||||||
|
)]
|
||||||
public IReadOnlyList<Snowflake> ChannelIds { get; init; } = Array.Empty<Snowflake>();
|
public IReadOnlyList<Snowflake> ChannelIds { get; init; } = Array.Empty<Snowflake>();
|
||||||
|
|
||||||
public override async ValueTask ExecuteAsync(IConsole console)
|
public override async ValueTask ExecuteAsync(IConsole console)
|
||||||
|
|
|
@ -11,7 +11,12 @@ namespace DiscordChatExporter.Cli.Commands;
|
||||||
[Command("exportguild", Description = "Export all channels within specified guild.")]
|
[Command("exportguild", Description = "Export all channels within specified guild.")]
|
||||||
public class ExportGuildCommand : ExportCommandBase
|
public class ExportGuildCommand : ExportCommandBase
|
||||||
{
|
{
|
||||||
[CommandOption("guild", 'g', IsRequired = true, Description = "Guild ID.")]
|
[CommandOption(
|
||||||
|
"guild",
|
||||||
|
'g',
|
||||||
|
IsRequired = true,
|
||||||
|
Description = "Guild ID."
|
||||||
|
)]
|
||||||
public Snowflake GuildId { get; init; }
|
public Snowflake GuildId { get; init; }
|
||||||
|
|
||||||
public override async ValueTask ExecuteAsync(IConsole console)
|
public override async ValueTask ExecuteAsync(IConsole console)
|
||||||
|
|
|
@ -12,7 +12,12 @@ namespace DiscordChatExporter.Cli.Commands;
|
||||||
[Command("channels", Description = "Get the list of channels in a guild.")]
|
[Command("channels", Description = "Get the list of channels in a guild.")]
|
||||||
public class GetChannelsCommand : TokenCommandBase
|
public class GetChannelsCommand : TokenCommandBase
|
||||||
{
|
{
|
||||||
[CommandOption("guild", 'g', IsRequired = true, Description = "Guild ID.")]
|
[CommandOption(
|
||||||
|
"guild",
|
||||||
|
'g',
|
||||||
|
IsRequired = true,
|
||||||
|
Description = "Guild ID."
|
||||||
|
)]
|
||||||
public Snowflake GuildId { get; init; }
|
public Snowflake GuildId { get; init; }
|
||||||
|
|
||||||
public override async ValueTask ExecuteAsync(IConsole console)
|
public override async ValueTask ExecuteAsync(IConsole console)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue