Use nullable

This commit is contained in:
Alexey Golub
2019-11-13 19:19:36 +02:00
parent 1bf9d9e2e2
commit e5a2852165
42 changed files with 195 additions and 196 deletions

View File

@@ -7,7 +7,6 @@ using CliFx.Utilities;
using DiscordChatExporter.Core.Models;
using DiscordChatExporter.Core.Services;
using DiscordChatExporter.Core.Services.Helpers;
using Tyrrrz.Extensions;
namespace DiscordChatExporter.Cli.Commands
{
@@ -22,7 +21,7 @@ namespace DiscordChatExporter.Cli.Commands
public ExportFormat ExportFormat { get; set; } = ExportFormat.HtmlDark;
[CommandOption("output", 'o', Description = "Output file or directory path.")]
public string OutputPath { get; set; }
public string? OutputPath { get; set; }
[CommandOption("after",Description = "Limit to messages sent after this date.")]
public DateTimeOffset? After { get; set; }
@@ -34,7 +33,7 @@ namespace DiscordChatExporter.Cli.Commands
public int? PartitionLimit { get; set; }
[CommandOption("dateformat", Description = "Date format used in output.")]
public string DateFormat { get; set; }
public string? DateFormat { get; set; }
protected ExportCommandBase(SettingsService settingsService, DataService dataService, ExportService exportService)
: base(dataService)
@@ -46,8 +45,8 @@ namespace DiscordChatExporter.Cli.Commands
protected async Task ExportChannelAsync(IConsole console, Channel channel)
{
// Configure settings
if (!DateFormat.IsNullOrWhiteSpace())
SettingsService.DateFormat = DateFormat;
if (!string.IsNullOrWhiteSpace(DateFormat))
SettingsService.DateFormat = DateFormat!;
console.Output.Write($"Exporting channel [{channel.Name}]... ");
var progress = console.CreateProgressTicker();
@@ -57,7 +56,7 @@ namespace DiscordChatExporter.Cli.Commands
// Generate file path if not set or is a directory
var filePath = OutputPath;
if (filePath.IsNullOrWhiteSpace() || ExportHelper.IsDirectoryPath(filePath))
if (string.IsNullOrWhiteSpace(filePath) || ExportHelper.IsDirectoryPath(filePath))
{
// Generate default file name
var fileName = ExportHelper.GetDefaultExportFileName(ExportFormat, chatLog.Guild,