Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(GH-135) Adds a Console Runner to GetChocolatey #131

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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