Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 23, 2025

Replaces custom argument parsing in tools/LinkDotNet.Blog.UpgradeAssistant/Program.cs with CommandLineParser library and adopts centralized package versioning via Directory.Packages.props.

Changes

  • CommandLineOptions.cs (new): Defines command-line options using CommandLineParser attributes
  • Program.cs:
    • Uses Parser.Default.ParseArguments<CommandLineOptions>() instead of custom parsing logic
    • Removes 27 lines of manual argument handling
    • Maintains custom help/version display using Spectre.Console (consistent with CriticalCSS tool pattern)
  • LinkDotNet.Blog.UpgradeAssistant.csproj: Adds CommandLineParser package reference (version managed centrally)

Before/After

// Before: Manual parsing with switch statement
static void ParseCommandLineArguments(string[] args, ref string targetPath, ...)
{
    var i = 0;
    while (i < args.Length) {
        switch (args[i]) {
            case "-p" or "--path" when i + 1 < args.Length:
                i++; targetPath = args[i]; break;
            // ...
        }
    }
}

// After: Declarative options with CommandLineParser
public class CommandLineOptions
{
    [Option('p', "path", Required = false, Default = ".")]
    public string TargetPath { get; init; } = ".";
    // ...
}

return await Parser.Default.ParseArguments<CommandLineOptions>(args)
    .MapResult(async opts => await RunWithOptions(opts), _ => Task.FromResult(1));
Original prompt

For tools/LinkDotNet.Blog.UpgradeAssistant/Program.cs use CommandLineParser to parse the arguments rather than the custom made solution. Adopt the Directory.Packages.props as well


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Update argument parsing using CommandLineParser Refactor UpgradeAssistant to use CommandLineParser Dec 23, 2025
Copilot AI requested a review from linkdotnet December 23, 2025 20:43
@linkdotnet linkdotnet marked this pull request as ready for review December 23, 2025 20:44
@linkdotnet linkdotnet merged commit 4a2f390 into master Dec 23, 2025
3 checks passed
@linkdotnet linkdotnet deleted the copilot/update-command-line-parser branch December 23, 2025 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants