/// <summary> /// Main entry. /// </summary> public static void Main(string[] args) { GetOpt opt = new GetOpt(args, "Dhs:"); char c; Load(cpu, cLoad, 0, 0); Load(mem, mLoad, 0, 0); Load(net, nLoad, 0, 0); Load(dsk, dLoad, 0, 0); while ((c = opt.Next()) != '-') { switch (c) { case 'D': DumpSpecs(); System.Environment.Exit(0); break; case 'h': Usage(0); break; case 's': LoadSpecs(opt.Argument); break; default: Console.Error.WriteLine(opt.Error); Usage(1); break; } } if ((args.Length - opt.Index) < 2) { Usage(1); } Random r = new Random(); try { int cnt = Int32.Parse(args[opt.Index + 1]); using (StreamWriter w = new StreamWriter(args[opt.Index])) { for (int i = 0; i < cnt; i++) { w.Write("srv" + (i + 1) + ", "); w.Write(cpu[r.Next(0, cpu.Count - 1)] + ", "); w.Write(mem[r.Next(0, mem.Count - 1)] + ", "); w.Write(net[r.Next(0, net.Count - 1)] + ", "); w.WriteLine(dsk[r.Next(0, dsk.Count - 1)]); } } } catch (Exception ex) { Console.Error.WriteLine(ex.Message); } }
/// <summary> /// Main. /// </summary> /// <param name="args">Command line arguments</param> public static void Main(string[] args) { GetOpt opt = new GetOpt(args, "A:O:S:chn:o:r:s:v"); Reservation res = null; bool v = false, calculate = false; string scOutputDir = null, scName = null, selectors = "cmn", styles = null; string outputFormat = "html"; char c; while ((c = opt.Next()) != '-') { switch (c) { case 'A': if (sc.SetAlgorithm(opt.Argument, 0, false) == false) { Usage(1); } break; case 'O': outputFormat = opt.Argument; break; case 'S': styles = opt.Argument; break; case 'c': calculate = true; break; case 'h': Usage(0); break; case 'n': scName = opt.Argument; break; case 'o': scOutputDir = opt.Argument; break; case 'r': res = new Reservation(opt.Argument); break; case 's': if ((selectors = sc.TrimSelectors(opt.Argument, 0)) == null) { Usage(1); } sc.selectors = selectors; break; case 'v': v = true; break; case '?': Errors.Error(opt.Error); Usage(1); break; } } if ((args.Length - opt.Index) < 1) { Usage(1); } Verbose.verbose = v; try { sc.Init(args[opt.Index], res, scName, styles, calculate); sc.Load(); sc.Run(); string o = outputFormat.ToLower(); OutputFormat op; if (o == "html") { op = new HtmlOutput(sc, scOutputDir); } else if (o == "text") { op = new TextOutput(sc, scOutputDir); } else { throw new Exception("Unknown output format: '" + outputFormat + "'"); } op.Output(); } catch (Exception ex) { Console.Error.WriteLine(ex.ToString()); System.Environment.Exit(1); } }