using System; using System.Text; using System.Diagnostics; using System.Reflection; using System.IO; using System.Collections.Generic; namespace cscz { class Program { public static void Main(string[] args) { Dictionary parsedArgs = new Dictionary(); ParseOptions(args, new List(), new List(){ "help", "private" }); 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; } ClassGenerator cg = new ClassGenerator(); string source = Console.In.ReadToEnd(); cg.ParseString(source); cg.CreateProperties = !parsedArgs.ContainsKey("private"); Console.WriteLine(cg); } /// /// Parses command line options out into a dictionary. /// /// The arguments to parse. /// A list in which to dump any extra arguments found that aren't attached to a flag. /// A list of flags which do not take a value. /// The parsed arguments. static Dictionary ParseOptions(string[] args, List extraArgs, List noValueArgs) { Dictionary result = new Dictionary(); 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; } } }