diff --git a/Resumer/cli/commands/get/GetJobCommand.cs b/Resumer/cli/commands/get/GetJobCommand.cs index f70fb97..d679c34 100644 --- a/Resumer/cli/commands/get/GetJobCommand.cs +++ b/Resumer/cli/commands/get/GetJobCommand.cs @@ -32,7 +32,7 @@ public override int Execute(CommandContext context, GetJobCommandSettings settin public class GetJobCommandSettings: OutputCommandSettings { - public Table? CreateTable() + public override Table? CreateTable() { var table = CreateTable("Jobs"); if(table == null) return table; diff --git a/Resumer/cli/commands/get/GetProfileCommand.cs b/Resumer/cli/commands/get/GetProfileCommand.cs index 34cd5b4..a0ff67d 100644 --- a/Resumer/cli/commands/get/GetProfileCommand.cs +++ b/Resumer/cli/commands/get/GetProfileCommand.cs @@ -30,7 +30,7 @@ public override int Execute(CommandContext context, GetProfileCommandSettings se public class GetProfileCommandSettings: OutputCommandSettings { - public Table? CreateTable() + public override Table? CreateTable() { var table = this.CreateTable("Profile"); if(table == null) return table; diff --git a/Resumer/cli/commands/get/GetProjectCommand.cs b/Resumer/cli/commands/get/GetProjectCommand.cs index 70c73a4..679939c 100644 --- a/Resumer/cli/commands/get/GetProjectCommand.cs +++ b/Resumer/cli/commands/get/GetProjectCommand.cs @@ -30,7 +30,7 @@ public class GetProjectSettings: OutputCommandSettings { public string ProjectName { get; set; } - public Table? CreateTable() + public override Table? CreateTable() { var table = CreateTable("Projects"); if(table == null) return table; diff --git a/Resumer/cli/commands/get/GetSkillCommand.cs b/Resumer/cli/commands/get/GetSkillCommand.cs index 93548c3..395de1b 100644 --- a/Resumer/cli/commands/get/GetSkillCommand.cs +++ b/Resumer/cli/commands/get/GetSkillCommand.cs @@ -31,7 +31,7 @@ public override int Execute(CommandContext context, GetSkillCommandSettings sett public class GetSkillCommandSettings: OutputCommandSettings { - public Table? CreateTable() + public override Table? CreateTable() { var table = CreateTable("Skills"); if(table == null) return table; diff --git a/Resumer/cli/commands/get/GetTypstTemplateCommand.cs b/Resumer/cli/commands/get/GetTypstTemplateCommand.cs index 7071301..bbe9621 100644 --- a/Resumer/cli/commands/get/GetTypstTemplateCommand.cs +++ b/Resumer/cli/commands/get/GetTypstTemplateCommand.cs @@ -62,7 +62,7 @@ public class GetTypstTemplateCommandSettings: OutputCommandSettings [Description("template name")] public string? Name { get; init; } - public Table? CreateTable() + public override Table? CreateTable() { var table = base.CreateTable("Templates"); if(table == null) return table; diff --git a/Resumer/cli/commands/get/OutputCommandSettings.cs b/Resumer/cli/commands/get/OutputCommandSettings.cs index 9fb7de1..c5ff606 100644 --- a/Resumer/cli/commands/get/OutputCommandSettings.cs +++ b/Resumer/cli/commands/get/OutputCommandSettings.cs @@ -1,6 +1,4 @@ -using System.Collections.Immutable; using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text; using Spectre.Console; @@ -8,7 +6,7 @@ namespace Resumer.cli.commands.get; -public class OutputCommandSettings: CommandSettings +public abstract class OutputCommandSettings: CommandSettings { [CommandOption("-o|--format")] [Description("output format")] @@ -33,35 +31,13 @@ public class OutputCommandSettings: CommandSettings public bool Footer { get; set; } - public Table? CreateTable<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T>( - string? title = null, string? caption = null) where T : notnull - { - var table = CreateTable(title, caption); - - if(table == null) - return null; - - var type = typeof(T); - - - type.GetProperties() - .Where(prop => prop.CanRead) - .Select(prop => prop.Name) - .ToImmutableList() - .ForEach(name => table.AddColumn(new TableColumn(name))); - - table.Title = new TableTitle($"{type.Name}s"); - - return table; - } - /// /// /// /// /// /// if null raw/plain output was requested - public Table? CreateTable(string? title = null, string? caption = null) + public Table? CreateTable(string? title, string? caption = null) { if(Raw) return null; @@ -80,6 +56,8 @@ public class OutputCommandSettings: CommandSettings return table; } + public virtual Table? CreateTable() => throw new NotImplementedException("must be implemented in derived classes"); + public string Output(Table table) { var output = string.Empty;