예제 #1
0
        /// <summary>
        /// Entry point for SimpleVersion invocation.
        /// </summary>
        /// <param name="args">The array of arguments.</param>
        /// <returns>0 if success, otherwise an error exit code.</returns>
        public static int Main(string[] args)
        {
            var exitCode = 0;

            try
            {
                var path = System.IO.Directory.GetCurrentDirectory();
                if (args.Length > 0)
                {
                    path = args[0];
                }

                var result = VersionCalculator
                             .Default()
                             .GetResult(path);

                Console.Out.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch (Exception ex)
            {
                Console.Error.WriteLine($"[Error] {ex.Message}");
                exitCode = -1;
            }
#pragma warning restore CA1031 // Do not catch general exception types

            return(exitCode);
        }
예제 #2
0
        public static VersionResult SimpleVersion(
            this ICakeContext context,
            string path = null)
        {
            if (string.IsNullOrWhiteSpace(path))
            {
                path = context.Environment.WorkingDirectory.FullPath;
            }

            return(VersionCalculator
                   .Default()
                   .GetResult(path));
        }
예제 #3
0
 private static Model.VersionResult GetResult(RepositoryFixtureBase repo) => VersionCalculator.Default().GetResult(repo.RepositoryPath);