public bool ParseArgs(string[] args) { GetOpt programArgs = new GetOpt(args); try { programArgs.SetOpts(new string[] { "d" }); programArgs.Parse(); } catch (ArgumentException e) { Console.WriteLine(e.Message); return(false); } _Debug = programArgs.IsDefined("d"); _PathList.Clear(); foreach (string s in programArgs.Args) { _PathList.Add(s); } return(true); }
public bool ParseArgs(string[] args) { GetOpt programArgs = new GetOpt(args); try { programArgs.SetOpts(new string[] { "d", "x", "e", "r", "o=" }); programArgs.Parse(); } catch (ArgumentException e) { Console.WriteLine(e.Message); return(false); } _Debug = programArgs.IsDefined("d"); _ForceENaming = programArgs.IsDefined("e"); _ForceXNaming = programArgs.IsDefined("x"); _UseRelativeNaming = programArgs.IsDefined("r"); if (programArgs.IsDefined("o")) { _OutputPath = programArgs.GetOptionArg("o"); } _PathList.Clear(); foreach (string s in programArgs.Args) { _PathList.Add(s); } return(true); }
public static void Main(string[] args) { GetOpt oGetOpt = new GetOpt(args); string MdbFile = ""; try { oGetOpt.SetOpts(new string[] { "c", "d=", "s=" }); oGetOpt.Parse(); //DEBUG: Console.WriteLine("Successfully parsed arguments."); } catch (ArgumentException) { Console.Error.WriteLine("ERROR: arguments not supplied"); //TODO: Write usage info function oGetOpt.Args.ToString(); Console.WriteLine(); System.Environment.Exit(666); } if (!oGetOpt.IsDefined("d")) { Console.Error.WriteLine("Must specify the database."); System.Environment.Exit(666); } else { MdbFile = oGetOpt.GetOptionArg("d"); } Console.WriteLine("Database: {0}", MdbFile); try { if (oGetOpt.HasArgument("s")) { Console.WriteLine("SQL Script: {0}", oGetOpt.GetOptionArg("s")); } } catch (ArgumentNullException) { } if (oGetOpt.IsDefined("c")) { if (File.Exists(MdbFile)) { Console.Error.WriteLine("JetSQL file \"{0}\" already exists!", MdbFile); } else { JetSqlUtil.CreateMDB(MdbFile); } } //If the Access file doesn't exist at this point we can't go on if (!File.Exists(MdbFile)) { Console.Error.WriteLine("JetSQL file \"{0}\" does not exist!", MdbFile); } if (oGetOpt.IsDefined("s")) { OdbcDba dbconn = new OdbcDba(); dbconn.ConnectMDB(MdbFile); dbconn.ExecuteSqlFile(oGetOpt.GetOptionArg("s")); dbconn.Disconnect(); } }