From 6d3ddf1becce182f62580811e48a3ea186f006ca Mon Sep 17 00:00:00 2001 From: Matt Wrock Date: Sat, 28 Feb 2015 13:15:47 -0800 Subject: [PATCH] (GH-135) Adds a Console Runner to GetChocolatey Add a `RunConsole` overload that can parse commandline args with the Console runner. I'd like to use this with Boxstarter since it simply intercepts user choco calls via unparsed commandline args. --- src/chocolatey/GetChocolatey.cs | 37 ++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/chocolatey/GetChocolatey.cs b/src/chocolatey/GetChocolatey.cs index fdf5d97878..e6487625e5 100644 --- a/src/chocolatey/GetChocolatey.cs +++ b/src/chocolatey/GetChocolatey.cs @@ -167,21 +167,24 @@ public GetChocolatey RegisterContainerComponents(Action containerSetu /// public void Run() { - //refactor - thank goodness this is temporary, cuz manifest resource streams are dumb - IList folders = new List - { - "helpers", - "functions", - "redirects", - "tools" - }; - - AssemblyFileExtractor.extract_all_resources_to_relative_directory(_container.GetInstance(), Assembly.GetAssembly(typeof(ChocolateyResourcesAssembly)), ApplicationParameters.InstallLocation, folders, ApplicationParameters.ChocolateyFileResources); + extract_resources(); var configuration = create_configuration(new List()); var runner = new GenericRunner(); runner.run(configuration, _container, isConsole: false, parseArgs: null); } + /// + /// Call this method to run chocolatey after you have set the options. + /// Commandline arguments to add to configuration. + /// + public void RunConsole(string[] args) + { + extract_resources(); + var configuration = create_configuration(new List(args)); + var runner = new ConsoleApplication(); + runner.run(args, configuration, _container); + } + private ChocolateyConfiguration create_configuration(IList args) { var configuration = new ChocolateyConfiguration(); @@ -196,6 +199,20 @@ private ChocolateyConfiguration create_configuration(IList args) } return configuration; } + + private void extract_resources() + { + //refactor - thank goodness this is temporary, cuz manifest resource streams are dumb + IList folders = new List + { + "helpers", + "functions", + "redirects", + "tools" + }; + + AssemblyFileExtractor.extract_all_resources_to_relative_directory(_container.GetInstance(), Assembly.GetAssembly(typeof(ChocolateyResourcesAssembly)), ApplicationParameters.InstallLocation, folders, ApplicationParameters.ChocolateyFileResources); + } } // ReSharper restore InconsistentNaming