Skip to content

Commit

Permalink
Merge pull request #138 from mwrock/console_runner
Browse files Browse the repository at this point in the history
(GH-135) Adds a Console Runner to GetChocolatey
  • Loading branch information
ferventcoder committed Mar 2, 2015
2 parents 8d28505 + 6d3ddf1 commit 07ff24a
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions src/chocolatey/GetChocolatey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,21 +167,24 @@ public GetChocolatey RegisterContainerComponents(Action<Container> containerSetu
/// </summary>
public void Run()
{
//refactor - thank goodness this is temporary, cuz manifest resource streams are dumb
IList<string> folders = new List<string>
{
"helpers",
"functions",
"redirects",
"tools"
};

AssemblyFileExtractor.extract_all_resources_to_relative_directory(_container.GetInstance<IFileSystem>(), Assembly.GetAssembly(typeof(ChocolateyResourcesAssembly)), ApplicationParameters.InstallLocation, folders, ApplicationParameters.ChocolateyFileResources);
extract_resources();
var configuration = create_configuration(new List<string>());
var runner = new GenericRunner();
runner.run(configuration, _container, isConsole: false, parseArgs: null);
}

/// <summary>
/// Call this method to run chocolatey after you have set the options.
/// <param name="args">Commandline arguments to add to configuration.</param>
/// </summary>
public void RunConsole(string[] args)
{
extract_resources();
var configuration = create_configuration(new List<string>(args));
var runner = new ConsoleApplication();
runner.run(args, configuration, _container);
}

private ChocolateyConfiguration create_configuration(IList<string> args)
{
var configuration = new ChocolateyConfiguration();
Expand All @@ -196,6 +199,20 @@ private ChocolateyConfiguration create_configuration(IList<string> args)
}
return configuration;
}

private void extract_resources()
{
//refactor - thank goodness this is temporary, cuz manifest resource streams are dumb
IList<string> folders = new List<string>
{
"helpers",
"functions",
"redirects",
"tools"
};

AssemblyFileExtractor.extract_all_resources_to_relative_directory(_container.GetInstance<IFileSystem>(), Assembly.GetAssembly(typeof(ChocolateyResourcesAssembly)), ApplicationParameters.InstallLocation, folders, ApplicationParameters.ChocolateyFileResources);
}
}

// ReSharper restore InconsistentNaming
Expand Down

0 comments on commit 07ff24a

Please sign in to comment.