Update CliFx to v1.0

This commit is contained in:
Alexey Golub
2020-01-30 16:34:36 +02:00
parent 37be80e9e1
commit 8a4f306012
12 changed files with 26 additions and 28 deletions

View File

@@ -1,6 +1,6 @@
using System.Threading.Tasks;
using CliFx;
using CliFx.Attributes;
using CliFx.Services;
using DiscordChatExporter.Core.Services;
namespace DiscordChatExporter.Cli.Commands
@@ -16,6 +16,6 @@ namespace DiscordChatExporter.Cli.Commands
{
}
public override async Task ExecuteAsync(IConsole console) => await ExportAsync(console, ChannelId);
public override async ValueTask ExecuteAsync(IConsole console) => await ExportAsync(console, ChannelId);
}
}

View File

@@ -1,8 +1,8 @@
using System;
using System.IO;
using System.Threading.Tasks;
using CliFx;
using CliFx.Attributes;
using CliFx.Services;
using CliFx.Utilities;
using DiscordChatExporter.Core.Models;
using DiscordChatExporter.Core.Services;
@@ -40,7 +40,7 @@ namespace DiscordChatExporter.Cli.Commands
ExportService = exportService;
}
protected async Task ExportAsync(IConsole console, Guild guild, Channel channel)
protected async ValueTask ExportAsync(IConsole console, Guild guild, Channel channel)
{
if (!string.IsNullOrWhiteSpace(DateFormat))
SettingsService.DateFormat = DateFormat;
@@ -56,13 +56,13 @@ namespace DiscordChatExporter.Cli.Commands
console.Output.WriteLine();
}
protected async Task ExportAsync(IConsole console, Channel channel)
protected async ValueTask ExportAsync(IConsole console, Channel channel)
{
var guild = await DataService.GetGuildAsync(GetToken(), channel.GuildId);
await ExportAsync(console, guild, channel);
}
protected async Task ExportAsync(IConsole console, string channelId)
protected async ValueTask ExportAsync(IConsole console, string channelId)
{
var channel = await DataService.GetChannelAsync(GetToken(), channelId);
await ExportAsync(console, channel);

View File

@@ -1,8 +1,8 @@
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using CliFx;
using CliFx.Attributes;
using CliFx.Services;
using DiscordChatExporter.Core.Models.Exceptions;
using DiscordChatExporter.Core.Services;
using DiscordChatExporter.Core.Services.Exceptions;
@@ -17,7 +17,7 @@ namespace DiscordChatExporter.Cli.Commands
{
}
public override async Task ExecuteAsync(IConsole console)
public override async ValueTask ExecuteAsync(IConsole console)
{
// Get channels
var channels = await DataService.GetDirectMessageChannelsAsync(GetToken());

View File

@@ -1,8 +1,8 @@
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using CliFx;
using CliFx.Attributes;
using CliFx.Services;
using DiscordChatExporter.Core.Models;
using DiscordChatExporter.Core.Models.Exceptions;
using DiscordChatExporter.Core.Services;
@@ -21,7 +21,7 @@ namespace DiscordChatExporter.Cli.Commands
{
}
public override async Task ExecuteAsync(IConsole console)
public override async ValueTask ExecuteAsync(IConsole console)
{
// Get channels
var channels = await DataService.GetGuildChannelsAsync(GetToken(), GuildId);

View File

@@ -1,7 +1,7 @@
using System.Linq;
using System.Threading.Tasks;
using CliFx;
using CliFx.Attributes;
using CliFx.Services;
using DiscordChatExporter.Core.Models;
using DiscordChatExporter.Core.Services;
@@ -18,7 +18,7 @@ namespace DiscordChatExporter.Cli.Commands
{
}
public override async Task ExecuteAsync(IConsole console)
public override async ValueTask ExecuteAsync(IConsole console)
{
// Get channels
var channels = await DataService.GetGuildChannelsAsync(GetToken(), GuildId);

View File

@@ -1,7 +1,7 @@
using System.Linq;
using System.Threading.Tasks;
using CliFx;
using CliFx.Attributes;
using CliFx.Services;
using DiscordChatExporter.Core.Services;
namespace DiscordChatExporter.Cli.Commands
@@ -14,7 +14,7 @@ namespace DiscordChatExporter.Cli.Commands
{
}
public override async Task ExecuteAsync(IConsole console)
public override async ValueTask ExecuteAsync(IConsole console)
{
// Get channels
var channels = await DataService.GetDirectMessageChannelsAsync(GetToken());

View File

@@ -1,7 +1,7 @@
using System.Linq;
using System.Threading.Tasks;
using CliFx;
using CliFx.Attributes;
using CliFx.Services;
using DiscordChatExporter.Core.Services;
namespace DiscordChatExporter.Cli.Commands
@@ -14,7 +14,7 @@ namespace DiscordChatExporter.Cli.Commands
{
}
public override async Task ExecuteAsync(IConsole console)
public override async ValueTask ExecuteAsync(IConsole console)
{
// Get guilds
var guilds = await DataService.GetUserGuildsAsync(GetToken());

View File

@@ -2,14 +2,13 @@
using System.Threading.Tasks;
using CliFx;
using CliFx.Attributes;
using CliFx.Services;
namespace DiscordChatExporter.Cli.Commands
{
[Command("guide", Description = "Explains how to obtain token, guild or channel ID.")]
public class GuideCommand : ICommand
{
public Task ExecuteAsync(IConsole console)
public ValueTask ExecuteAsync(IConsole console)
{
console.WithForegroundColor(ConsoleColor.White, () => console.Output.WriteLine("To get user token:"));
console.Output.WriteLine(" 1. Open Discord");
@@ -48,7 +47,7 @@ namespace DiscordChatExporter.Cli.Commands
console.Output.WriteLine("If you still have unanswered questions, check out the wiki:");
console.Output.WriteLine("https://github.com/Tyrrrz/DiscordChatExporter/wiki");
return Task.CompletedTask;
return default;
}
}
}

View File

@@ -1,7 +1,6 @@
using System.Threading.Tasks;
using CliFx;
using CliFx.Attributes;
using CliFx.Services;
using DiscordChatExporter.Core.Models;
using DiscordChatExporter.Core.Services;
@@ -24,6 +23,6 @@ namespace DiscordChatExporter.Cli.Commands
protected AuthToken GetToken() => new AuthToken(IsBotToken ? AuthTokenType.Bot : AuthTokenType.User, TokenValue);
public abstract Task ExecuteAsync(IConsole console);
public abstract ValueTask ExecuteAsync(IConsole console);
}
}