2016-05-07 19:03:44 +00:00
|
|
|
|
using System;
|
2016-05-07 19:31:15 +00:00
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Diagnostics;
|
2016-05-08 11:14:34 +00:00
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.IO;
|
2016-05-08 11:51:57 +00:00
|
|
|
|
using System.Collections.Generic;
|
2016-05-07 19:03:44 +00:00
|
|
|
|
|
|
|
|
|
namespace cscz
|
|
|
|
|
{
|
|
|
|
|
class Program
|
|
|
|
|
{
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
{
|
2016-05-08 11:51:57 +00:00
|
|
|
|
Dictionary<string, string> parsedArgs = new Dictionary<string, string>();
|
|
|
|
|
ParseOptions(args, new List<string>(), new List<string>(){ "help", "private" });
|
|
|
|
|
|
2016-05-08 11:14:34 +00:00
|
|
|
|
if(args.Length >= 1 && args[0] == "--help")
|
|
|
|
|
{
|
|
|
|
|
Assembly asm = Assembly.GetExecutingAssembly();
|
|
|
|
|
/*** Debug - Lists the names of all embedded resources ***
|
|
|
|
|
foreach(string str in asm.GetManifestResourceNames())
|
|
|
|
|
Console.WriteLine(str);*/
|
|
|
|
|
StreamReader helpTextReader = new StreamReader(asm.GetManifestResourceStream(@"cscz.Help.md"));
|
|
|
|
|
string helpText = helpTextReader.ReadToEnd();
|
|
|
|
|
helpTextReader.Dispose();
|
|
|
|
|
Console.WriteLine(helpText);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-07 19:03:44 +00:00
|
|
|
|
ClassGenerator cg = new ClassGenerator();
|
2016-05-07 19:31:15 +00:00
|
|
|
|
|
|
|
|
|
string source = Console.In.ReadToEnd();
|
|
|
|
|
cg.ParseString(source);
|
|
|
|
|
|
2016-05-08 11:51:57 +00:00
|
|
|
|
cg.CreateProperties = !parsedArgs.ContainsKey("private");
|
|
|
|
|
|
2016-05-07 19:31:15 +00:00
|
|
|
|
Console.WriteLine(cg);
|
2016-05-07 19:03:44 +00:00
|
|
|
|
}
|
2016-05-08 11:51:57 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Parses command line options out into a dictionary.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="args">The arguments to parse.</param>
|
|
|
|
|
/// <param name="extraArgs">A list in which to dump any extra arguments found that aren't attached to a flag.</param>
|
|
|
|
|
/// <param name="noValueArgs">A list of flags which do not take a value.</param>
|
|
|
|
|
/// <returns>The parsed arguments.</returns>
|
|
|
|
|
static Dictionary<string, string> ParseOptions(string[] args, List<string> extraArgs, List<string> noValueArgs)
|
|
|
|
|
{
|
|
|
|
|
Dictionary<string, string> result = new Dictionary<string, string>();
|
|
|
|
|
for(int i = 0; i < args.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
if (args[i].StartsWith("-"))
|
|
|
|
|
{
|
|
|
|
|
string optionKey = args[i].Trim(new char[] { '-', ' ' });
|
|
|
|
|
if (i < args.Length - 1 && !args[i + 1].StartsWith("-"))
|
|
|
|
|
{
|
|
|
|
|
if(!noValueArgs.Contains(optionKey))
|
|
|
|
|
{
|
|
|
|
|
result[optionKey] = args[i + 1].Trim();
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result[optionKey] = "true";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result[optionKey] = "true";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
extraArgs.Add(args[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2016-05-07 19:03:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|