/// <summary> /// The main entry point for the application. /// </summary> public void execute(Options opts) { string input = null; VersionUpdater updater = null; /////////////////////////////////////////////////////////////////// // Get the input input = GetInput(opts); /////////////////////////////////////////////////////////////////// // Update the version number in the input updater = new VersionUpdater(input, opts); /////////////////////////////////////////////////////////////////// // Write the output WriteOutput(updater.Output, opts); }
public static int Main(string[] args) { Options options = null; string input = null; VersionUpdater updater = null; /////////////////////////////////////////////////////////////////// // Parse the command line try { options = new Options(args); } catch (Exception e) { Console.Error.WriteLine("Error parsing command line options."); Console.Error.WriteLine(e); Console.Error.WriteLine(); Console.Error.WriteLine(Options.Usage); return(1); } /////////////////////////////////////////////////////////////////// // Get the input try { input = GetInput(options); } catch (Exception e) { Console.Error.WriteLine("Error reading input."); Console.Error.WriteLine(e); return(2); } /////////////////////////////////////////////////////////////////// // Update the version number in the input try { updater = new VersionUpdater(input, options); } catch (Exception e) { Console.Error.WriteLine("Error updating version."); Console.Error.WriteLine(e); return(3); } /////////////////////////////////////////////////////////////////// // Write the output try { WriteOutput(updater.Output, options); } catch (Exception e) { Console.Error.WriteLine("Error writing output."); Console.Error.WriteLine(e); return(4); } // Return normally return(0); }
public static int Main(string[] args) { Options options = null; string input = null; VersionUpdater updater = null; /////////////////////////////////////////////////////////////////// // Parse the command line try { options = new Options(args); } catch(Exception e) { Console.Error.WriteLine("Error parsing command line options."); Console.Error.WriteLine(e); Console.Error.WriteLine(); Console.Error.WriteLine(Options.Usage); return 1; } /////////////////////////////////////////////////////////////////// // Get the input try { input = GetInput(options); } catch(Exception e) { Console.Error.WriteLine("Error reading input."); Console.Error.WriteLine(e); return 2; } /////////////////////////////////////////////////////////////////// // Update the version number in the input try { updater = new VersionUpdater(input, options); } catch(Exception e) { Console.Error.WriteLine("Error updating version."); Console.Error.WriteLine(e); return 3; } /////////////////////////////////////////////////////////////////// // Write the output try { WriteOutput(updater.Output, options); } catch(Exception e) { Console.Error.WriteLine("Error writing output."); Console.Error.WriteLine(e); return 4; } // Return normally return 0; }
/// <summary> /// The main entry point for the application. /// </summary> public void execute(Options opts) { string input = null; VersionUpdater updater = null; /////////////////////////////////////////////////////////////////// // Get the input input = GetInput(opts); /////////////////////////////////////////////////////////////////// // Update the version number in the input updater = new VersionUpdater(input, opts); /////////////////////////////////////////////////////////////////// // Write the output WriteOutput(updater.Output, opts); }
public override bool Execute() { List<String> buildoptions = new List<string>(); Options options = null; string input = null; VersionUpdater updater = null; StringBuilder message = new StringBuilder(); /////////////////////////////////////////////////////////////////// // validate the options try { if (string.IsNullOrEmpty(m_startDateOption) == false) { buildoptions.Add("-s"); buildoptions.Add(m_startDateOption); } if (string.IsNullOrEmpty(m_buildOption) == false) { buildoptions.Add("-b"); buildoptions.Add(m_buildOption); } if (string.IsNullOrEmpty(m_pinOption) == false) { buildoptions.Add("-p"); buildoptions.Add(m_pinOption); } if (string.IsNullOrEmpty(m_revisionOption) == false) { buildoptions.Add("-r"); buildoptions.Add(m_revisionOption); } if (string.IsNullOrEmpty(m_inputFile) == false) { buildoptions.Add("-i"); buildoptions.Add(m_inputFile); } if (string.IsNullOrEmpty(m_outputFile) == false) { buildoptions.Add("-o"); buildoptions.Add(m_outputFile); } if (string.IsNullOrEmpty(m_versionOption) == false) { buildoptions.Add("-v"); buildoptions.Add(m_versionOption); } options = new Options(buildoptions.ToArray()); } catch (Exception e) { message.AppendLine("Error validating options."); message.AppendLine(e.Message); message.AppendLine(); message.AppendLine(Options.Usage); Log.LogError(message.ToString()); return false; } /////////////////////////////////////////////////////////////////// // Get the input try { input = GetInput(options); } catch (Exception e) { message.AppendLine("Error reading input."); message.AppendLine(e.Message); Log.LogError(message.ToString()); return false; } /////////////////////////////////////////////////////////////////// // Update the version number in the input try { updater = new VersionUpdater(input, options); } catch (Exception e) { message.AppendLine("Error updating version."); message.AppendLine(e.Message); Log.LogError(message.ToString()); return false; } /////////////////////////////////////////////////////////////////// // Write the output try { m_updatedInput = updater.Output; if (String.IsNullOrEmpty(options.OutputFilename) == false) { using (StreamWriter writer = new StreamWriter(options.OutputFilename, false, Encoding.Default)) { writer.Write(m_updatedInput); } } } catch (Exception e) { message.AppendLine("Error writing output."); message.AppendLine(e.Message); Log.LogError(message.ToString()); return false; } // Return normally return true; }