Skip to content

Commit 0ddbf0d

Browse files
committed
Provide config switch to autogenerate default mappigns.
1 parent 5af5008 commit 0ddbf0d

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

ColorCat/ColorCatOptions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ public class ColorCatOptions
2323
[ValueList(typeof(List<string>))]
2424
public IList<string> Pattern { get; set; }
2525

26+
[Option("saveDefaultConfig", HelpText = "Overwrites the current configuration with the defaults.")]
27+
public bool SaveDefaults { get; set; }
28+
2629
[HelpOption]
2730
public string GetUsage()
2831
{

ColorCat/Program.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Linq;
43

54
namespace ColorCat
@@ -16,6 +15,10 @@ public static void Main(string[] args)
1615
{
1716
AddConfig(options);
1817
}
18+
else if (options.SaveDefaults)
19+
{
20+
SaveDefaults();
21+
}
1922
else
2023
{
2124
Run(options);
@@ -85,5 +88,12 @@ private static ColorMapping CreateMapping(ColorCatOptions options)
8588

8689
return mapping;
8790
}
91+
92+
private static void SaveDefaults()
93+
{
94+
var mappingJson = Configuration.SaveDefaults();
95+
Console.WriteLine("Default mappings saved. Current mappings are:");
96+
Console.WriteLine(mappingJson);
97+
}
8898
}
8999
}

0 commit comments

Comments
 (0)