-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDefaultConfigGenerator.cs
More file actions
32 lines (26 loc) · 1.04 KB
/
DefaultConfigGenerator.cs
File metadata and controls
32 lines (26 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System.IO;
using System.Reflection;
public class DefaultConfigGenerator
{
private const string defaultConfigFilename = "dotgraphee-config.json";
public void CreateDefaultConfig()
{
var here = Directory.GetCurrentDirectory();
Log.Write("Writing default configuration to: '" + Path.Join(here, defaultConfigFilename) + "' ...");
WriteToFile(ReadDefaultConfigResource());
Log.Write("Done!");
Log.Write("Modify the configuration file, then run 'dotgraphee " + defaultConfigFilename + "'.");
Log.Write("To make life easy, all default values are valid.");
}
private string ReadDefaultConfigResource()
{
var assembly = Assembly.GetEntryAssembly();
var resourceStream = assembly.GetManifestResourceStream("dotgraphee.default-config.json");
var reader = new StreamReader(resourceStream);
return reader.ReadToEnd();
}
private void WriteToFile(string content)
{
File.WriteAllLines(defaultConfigFilename, new[] { content });
}
}