Skip to content

Commit

Permalink
🐛 fix spacing and captilization of (enums)
Browse files Browse the repository at this point in the history
noticeable in education degrees

add option to select individual description for each job
  • Loading branch information
csc530 committed Aug 26, 2024
1 parent ccd3845 commit 7e75f37
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 28 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/generate_executables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# ensure tags are fetched; https://github.com/adamralph/minver?tab=readme-ov-file#why-is-the-default-version-sometimes-used-in-github-actions-azure-pipelines-and-travis-ci-when-a-version-tag-exists-in-the-history
with:
fetch-depth: 0
filter: tree:0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
Expand Down Expand Up @@ -72,7 +76,7 @@ jobs:
with:
name: ${{ matrix.os }}_resumer_${{ env.tag }}
path: ${{ matrix.os }}_resumer_${{ env.tag }}


- name: Set Output
id: set-output
Expand Down
30 changes: 8 additions & 22 deletions Resumer/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ public static string Print(this object? value) =>
null => string.Empty,
bool bit => bit ? "true" : "false",
string txt => txt,
Enum @enum => NextToUppercaseRegex().Replace(@enum.ToString(), "$1 $2").Replace('_', '-'),
Enum @enum => NextWordToUppercaseRegex().Replace(@enum.ToString(), "$1 $2").Replace('_', '-'),
DictionaryEntry pair => $"{pair.Key.Print()}: {pair.Value.Print()}",
IDictionary dictionary => string.Join("\n", dictionary.Cast<object>().Select(obj => $"- {obj.Print()}")),
IEnumerable enumerable => string.Join("\n", enumerable.Cast<object>().Select(obj => $"+ {obj.Print()}")),
_ => value.ToString() ?? string.Empty,
};

public static string Escape(this string value, string escapeValues) =>
private static string Escape(this string value, string escapeValues) =>
escapeValues.Aggregate(value,
(current, escapeValue) => current.Replace($"{escapeValue}", $"\\{escapeValue}"));

Expand All @@ -111,6 +111,8 @@ public static string ToTypstString(this object? obj, int pretty = -1)
return "none";
case string value:
return $"\"{value.Escape("\"")}\"";
case Enum @enum:
return $"\"{@enum.Print()}\"";
case int or double or float or long or ulong or short or ushort or byte or sbyte or decimal or char:
return obj.ToString() ?? "none";
case bool value:
Expand Down Expand Up @@ -180,7 +182,7 @@ public static string ToTypstString(this object? obj, int pretty = -1)
}
default:
{
//? get all public readable properties and convert to key-value typst strings
//? get all public-readable properties and convert to key-value typst strings
var properties = obj.GetType()
.GetProperties()
.Where(prop => prop.CanRead && Array.Exists(
Expand Down Expand Up @@ -221,9 +223,9 @@ public static string ToTypstString(this object? obj, int pretty = -1)

#endregion

public static void AddFromPrompt<T>(this List<T> list, string prompt)
public static void AddFromPrompt<T>(this List<T> list, string prompt) where T : class
{
var textPrompt = Utility.SimplePrompt<T>(prompt);
TextPrompt<T> textPrompt =new TextPrompt<T>(prompt);
T input;

do
Expand All @@ -234,22 +236,6 @@ public static void AddFromPrompt<T>(this List<T> list, string prompt)
} while(input != null && !string.IsNullOrWhiteSpace(input.ToString()));
}

public static List<string> AddFromPrompt(IEnumerable<string> list, string prompt)
{
var textPrompt = new TextPrompt<string?>(prompt).HideDefaultValue().AllowEmpty();
string? input;
var newlist = list.ToList();

do
{
input = AnsiConsole.Prompt(textPrompt);
if(!string.IsNullOrWhiteSpace(input))
newlist.Add(input);
} while(!string.IsNullOrWhiteSpace(input));

return newlist;
}

public static void EditFromPrompt(this List<string> description, string prompt)
{
string? input;
Expand Down Expand Up @@ -283,5 +269,5 @@ public static void EditFromPrompt(this List<string> description, string prompt)
}

[GeneratedRegex(@"(\w)([A-Z])")]
private static partial Regex NextToUppercaseRegex();
private static partial Regex NextWordToUppercaseRegex();
}
11 changes: 10 additions & 1 deletion Resumer/cli/commands/ExportCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ public override int Execute(CommandContext context, ExportCommandSettings settin
.NotRequired()
);

// ? select specific job details
if(jobs.Count != 0 && AnsiConsole.Confirm("Select specific job details?"))
foreach(var job in jobs)
if(job.Description.Count != 0)
job.Description =
AnsiConsole.Prompt(new MultiSelectionPrompt<string>().AddChoices(job.Description));
else
CommandOutput.Warn($"No specific job descriptions found for \"{job.ToString().EscapeMarkup()}\"");

if(!db.Skills.Any())
CommandOutput.Warn("No skills found");
else
Expand Down Expand Up @@ -85,7 +94,7 @@ public override int Execute(CommandContext context, ExportCommandSettings settin

var template = TypstTemplate.Default;

if(format == Formats.Pdf && db.Templates.Any())
if(format.IsTypstFormat() && db.Templates.Any())
template = AnsiConsole.Prompt(new SelectionPrompt<TypstTemplate>()
.Title("Select template")
.AddChoices(db.Templates)
Expand Down
9 changes: 5 additions & 4 deletions Resumer/models/Formats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,18 @@ namespace Resumer

public static partial class Utility
{
public static IEnumerable<string> FormatNames => Enum.GetNames<Formats>();
public static IEnumerable<Formats> Formats => Enum.GetValues<Formats>();

public static IEnumerable<Formats> TextFormats =>
Formats.Where(x => x.HasFlag(models.Formats.Text) && x != models.Formats.Text);

public static IEnumerable<string> TextFormatNames => TextFormats.Select(x => x.ToString());

public static IEnumerable<Formats> BinaryFormats =>
Formats.Where(x => x.HasFlag(models.Formats.Binary) && x != models.Formats.Binary);

public static IEnumerable<string> BinaryFormatNames => BinaryFormats.Select(x => x.ToString());
public static bool IsTypstFormat(this Formats format) =>
format == models.Formats.Pdf ||
format == models.Formats.Typ ||
format == models.Formats.Svg ||
format == models.Formats.Png;
}
}
2 changes: 2 additions & 0 deletions Resumer/resumer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

<SuppressTrimAnalysisWarnings>false</SuppressTrimAnalysisWarnings>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>

<MinVerTagPrefix>v</MinVerTagPrefix>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
Expand Down

0 comments on commit 7e75f37

Please sign in to comment.