Step 4 – refactoring the export command
Within the Export
folder, let’s create a new C# file named ExportCommand.cs
.
Every command class (including RootCommand
) derives from the Command
base class. Furthermore, that base class provides an AddCommand
method that takes a parameter of the Command
type, which also means any class that derives from the Command
class.
Armed with this, we can start refactoring the export
command by making the ExportCommand
class derive from Command
.
After importing the required using
statement, specifying the namespace
name, and adding the required class constructor, the first iteration of our class looks like this:
using System.CommandLine; namespace bookmarkr.Commands; public class ExportCommand : Command { #region Constructor public ExportCommand(string name, string? description = null) : base(name, description) &...