diff --git a/PersonaForge.csproj b/PersonaForge.csproj index 4a25ef0..f6e24eb 100644 --- a/PersonaForge.csproj +++ b/PersonaForge.csproj @@ -2,8 +2,8 @@ Exe - 0.5.101 - net9.0 + 0.5.102 + net8.0 enable enable true diff --git a/Program.cs b/Program.cs index 1149720..389ad0b 100644 --- a/Program.cs +++ b/Program.cs @@ -3,26 +3,34 @@ using PersonaForge; -var archetypeList = Archetypes.DefaultArchetypes(); -var archetypeDict = new Dictionary>(); - var rootCommand = new RootCommand("PersonaForge: Sims 2 Personality Generator"); var nameOption = new Option( name: "--name", - description: "Enter a name for the Sim"); + description: "Enter a name for the Sim" +); var archetypeOption = new Option( name: "--archetype", description: "The archetype template to base traits on", - getDefaultValue: () => "Random"); + getDefaultValue: () => "Random" +); + +var exportOption = new Option( + name: "--export", + description: "Export the generated profile to a file" +); rootCommand.AddOption(nameOption); rootCommand.AddOption(archetypeOption); +rootCommand.AddOption(exportOption); -rootCommand.SetHandler(async (string name, string archetype) => +rootCommand.SetHandler(async (string name, string archetype, bool export) => { - var traits = PersonalityGen.GenerateRandom(archetypeDict.GetValueOrDefault(archetype)); + var archetypeList = Archetypes.DefaultArchetypes(); + var archetypeDict = new Dictionary>(); + + var traits = PersonalityGen.GenerateRandom(archetypeDict.GetValueOrDefault(archetype, new())); var profile = new PersonaProfile { Name = name, @@ -30,7 +38,14 @@ rootCommand.SetHandler(async (string name, string archetype) => Archetype = archetype }; - Console.WriteLine(PersonaProfile.ToJson(profile)); -}, nameOption, archetypeOption); + Console.WriteLine($"--- Generated Profile ---{Environment.NewLine}{PersonaProfile.ToJson(profile)}"); + + if (export) + { + var safeName = name.Replace(" ", "_").Replace("\"", ""); + await File.WriteAllTextAsync($"{safeName}.json", PersonaProfile.ToJson(profile)); + } + +}, nameOption, archetypeOption, exportOption); return await rootCommand.InvokeAsync(args); diff --git a/README.md b/README.md index 826ec58..8892d9c 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ With Sims 3 and later, creating personalities is as simple as selecting a trait. ## 📦 Example ```shell -personaforge --name "Max Casey" --archetype "Party Animal" +personaforge --name "Max Casey" --archetype "Party Animal" (--export) ``` ```json