From c6a7d42f1f14523f9a0109ea3ff5148dc8ec1ee9 Mon Sep 17 00:00:00 2001 From: ryouji Date: Wed, 31 Jan 2024 15:59:56 +0800 Subject: [PATCH] fix title error display --- src/EpubBuilderCLI/Program.cs | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/EpubBuilderCLI/Program.cs b/src/EpubBuilderCLI/Program.cs index 2041a0a..740cd6c 100644 --- a/src/EpubBuilderCLI/Program.cs +++ b/src/EpubBuilderCLI/Program.cs @@ -26,13 +26,13 @@ private static void ParseArgs(string[] args) var rootCommand = new RootCommand(); var mdOption = new Option(aliases: ["-m", "--markdown"], description: "Markdown Path") { IsRequired = true }; - var coverOption = new Option(aliases: ["-c", "--cover"], description: "Cover Path", getDefaultValue: () => ""); - var buildOption = new Option(aliases: ["-b", "--build"], description: "Build Path", getDefaultValue: () => ""); - var languageOption = new Option(aliases: ["-l", "--language"], description: "Epub Language", getDefaultValue: () => "zh"); - var titleOption = new Option(aliases: ["-t", "--title"], description: "Epub Title", getDefaultValue: () => ""); - var authorOption = new Option(aliases: ["-a", "--author"], description: "Epub Author", getDefaultValue: () => "EpubBuilder"); - var uuidOption = new Option(aliases: ["-u", "--uuid"], description: "Epub universally unique identifier", getDefaultValue: () => ""); - var splitOption = new Option(aliases: ["-s", "--split"], description: "Split Level", getDefaultValue: () => 1); + var coverOption = new Option(aliases: ["-c", "--cover"], description: "Cover Path"); + var buildOption = new Option(aliases: ["-b", "--build"], description: "Build Path"); + var languageOption = new Option(aliases: ["-l", "--language"], description: "Epub Language"); + var titleOption = new Option(aliases: ["-t", "--title"], description: "Epub Title"); + var authorOption = new Option(aliases: ["-a", "--author"], description: "Epub Author"); + var uuidOption = new Option(aliases: ["-u", "--uuid"], description: "Epub universally unique identifier"); + var splitOption = new Option(aliases: ["-s", "--split"], description: "Split Level"); var buildCommand = new Command("build", "build epub book") { @@ -50,13 +50,13 @@ private static void ParseArgs(string[] args) { var buildCommandArgs = new BuildCommandArgs { - MdPath = mdpath, - CoverPath = cover, - BuildPath = build, - Language = language, - Title = title, - Author = author, - Uuid = uuid, + MdPath = mdpath ?? "", + CoverPath = cover ?? "", + BuildPath = build ?? "", + Language = language ?? "", + Title = title ?? "", + Author = author ?? "", + Uuid = uuid ?? "", SplitLevel = splitLevel }; @@ -79,7 +79,8 @@ private static (EpubMetadata epubMetadata, BuildMetadata buildMetadata, string b { var epubMetadata = new EpubMetadata { - Title = args.Title ?? Path.GetFileNameWithoutExtension(args.MdPath), + + Title = string.IsNullOrWhiteSpace(args.Title) ? Path.GetFileNameWithoutExtension(args.MdPath) : args.Title, Author = args.Author ?? "EpubBuilder", Language = args.Language ?? "zh", Uuid = args.Uuid ?? ""