Skip to content

Commit

Permalink
remove unused create table method
Browse files Browse the repository at this point in the history
  • Loading branch information
csc530 committed Jul 31, 2024
1 parent a9a1983 commit c7ee6d9
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Resumer/cli/commands/get/GetJobCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Resumer/cli/commands/get/GetProfileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Resumer/cli/commands/get/GetProjectCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Resumer/cli/commands/get/GetSkillCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Resumer/cli/commands/get/GetTypstTemplateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
30 changes: 4 additions & 26 deletions Resumer/cli/commands/get/OutputCommandSettings.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using System.Collections.Immutable;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Text;
using Spectre.Console;
using Spectre.Console.Cli;

namespace Resumer.cli.commands.get;

public class OutputCommandSettings: CommandSettings
public abstract class OutputCommandSettings: CommandSettings
{
[CommandOption("-o|--format")]
[Description("output format")]
Expand All @@ -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;
}

/// <summary>
///
/// </summary>
/// <param name="title"></param>
/// <param name="caption"></param>
/// <returns>if null raw/plain output was requested</returns>
public Table? CreateTable(string? title = null, string? caption = null)
public Table? CreateTable(string? title, string? caption = null)
{
if(Raw)
return null;
Expand All @@ -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;
Expand Down

0 comments on commit c7ee6d9

Please sign in to comment.