diff --git a/src/GitVersionExe/Runner.cs b/src/GitVersionExe/Runner.cs index ac0618157d..6be3e7ff18 100644 --- a/src/GitVersionExe/Runner.cs +++ b/src/GitVersionExe/Runner.cs @@ -2,6 +2,7 @@ namespace GitVersion { + using System.Linq; using GitVersion.Helpers; using GitVersion.Options; @@ -18,7 +19,33 @@ class InspectRunner { public static void Run(InspectOptions opts) { - throw new NotImplementedException(opts.GetType().Name); + var inputVariables = new InputVariables() + { + TargetPath = opts.Path, + }; + + var fs = new FileSystem(); + var allVariables = SpecifiedArgumentRunner.GetVariables(fs, inputVariables); + + // TODO: allow more variables + var showVariable = opts.Variables.First(); + + switch (showVariable) + { + case null: + // TODO: allow more output formatters + Console.WriteLine(JsonOutputFormatter.ToJson(allVariables)); + break; + + default: + string part; + if (!allVariables.TryGetValue(showVariable, out part)) + { + throw new WarningException(string.Format("'{0}' variable does not exist", showVariable)); + } + Console.WriteLine(part); + break; + } } } diff --git a/src/GitVersionExe/SpecifiedArgumentRunner.cs b/src/GitVersionExe/SpecifiedArgumentRunner.cs index 60de196ac9..05d3d3eee1 100644 --- a/src/GitVersionExe/SpecifiedArgumentRunner.cs +++ b/src/GitVersionExe/SpecifiedArgumentRunner.cs @@ -62,25 +62,6 @@ public static void Run(Arguments arguments, IFileSystem fileSystem) var variables = GetVariables(fileSystem, targetUrl, dynamicRepositoryLocation, authentication, targetBranch, noFetch, targetPath, commitId); - if (arguments.Output == OutputType.Json) - { - switch (arguments.ShowVariable) - { - case null: - Console.WriteLine(JsonOutputFormatter.ToJson(variables)); - break; - - default: - string part; - if (!variables.TryGetValue(arguments.ShowVariable, out part)) - { - throw new WarningException(string.Format("'{0}' variable does not exist", arguments.ShowVariable)); - } - Console.WriteLine(part); - break; - } - } - using (var assemblyInfoUpdate = new AssemblyInfoFileUpdate(arguments, targetPath, variables, fileSystem)) { var execRun = RunExecCommandIfNeeded(arguments, targetPath, variables);