Skip to content

Commit

Permalink
Move code to InspectRunner, for GitTools#428
Browse files Browse the repository at this point in the history
  • Loading branch information
serra committed Aug 24, 2015
1 parent 7feb103 commit b5a4dc9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
29 changes: 28 additions & 1 deletion src/GitVersionExe/Runner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace GitVersion
{
using System.Linq;
using GitVersion.Helpers;
using GitVersion.Options;

Expand All @@ -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;
}
}
}

Expand Down
19 changes: 0 additions & 19 deletions src/GitVersionExe/SpecifiedArgumentRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b5a4dc9

Please sign in to comment.