Export option
- Moved archetype variables into handler
This commit is contained in:
parent
499782924f
commit
8c33834975
3 changed files with 27 additions and 12 deletions
|
@ -2,8 +2,8 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<Version>0.5.101</Version>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Version>0.5.102</Version>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<PackAsTool>true</PackAsTool>
|
||||
|
|
33
Program.cs
33
Program.cs
|
@ -3,26 +3,34 @@
|
|||
|
||||
using PersonaForge;
|
||||
|
||||
var archetypeList = Archetypes.DefaultArchetypes();
|
||||
var archetypeDict = new Dictionary<string, Dictionary<string, double>>();
|
||||
|
||||
var rootCommand = new RootCommand("PersonaForge: Sims 2 Personality Generator");
|
||||
|
||||
var nameOption = new Option<string>(
|
||||
name: "--name",
|
||||
description: "Enter a name for the Sim");
|
||||
description: "Enter a name for the Sim"
|
||||
);
|
||||
|
||||
var archetypeOption = new Option<string>(
|
||||
name: "--archetype",
|
||||
description: "The archetype template to base traits on",
|
||||
getDefaultValue: () => "Random");
|
||||
getDefaultValue: () => "Random"
|
||||
);
|
||||
|
||||
var exportOption = new Option<bool>(
|
||||
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<string, Dictionary<string, double>>();
|
||||
|
||||
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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue