Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
* stable:
  (chocolateyGH-119) Report version
  • Loading branch information
ferventcoder committed Feb 25, 2015
2 parents d13dc17 + d931881 commit 7715e56
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/chocolatey.console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace chocolatey.console
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using infrastructure.adapters;
using infrastructure.app;
using infrastructure.app.builders;
Expand Down Expand Up @@ -58,7 +59,7 @@ private static void Main(string[] args)

var warnings = new List<string>();

ConfigurationBuilder.set_up_configuration(
ConfigurationBuilder.set_up_configuration(
args,
config,
fileSystem,
Expand All @@ -67,6 +68,8 @@ private static void Main(string[] args)
);
Config.initialize_with(config);

report_version_and_exit_if_requested(args, config);

trap_exit_scenarios(config);

if (config.RegularOuptut)
Expand Down Expand Up @@ -156,6 +159,19 @@ private static void Main(string[] args)
}
}

private static void report_version_and_exit_if_requested(string[] args, ChocolateyConfiguration config)
{
if (args == null || args.Length == 0) return;

var firstArg = args.FirstOrDefault();
if (firstArg.is_equal_to("-v") || firstArg.is_equal_to("--version"))
{
"chocolatey".Log().Info(ChocolateyLoggers.Important, () => "{0}".format_with(config.Information.ChocolateyProductVersion));
pause_execution_if_debug();
Environment.Exit(0);
}
}

static EventHandler _handler;

private static void trap_exit_scenarios(ChocolateyConfiguration config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ public static void parse_arguments_and_update_configuration(ICollection<string>
{
configuration.CommandName = commandName;
}
else if (commandName.is_equal_to("-v") || commandName.is_equal_to("--version"))
{
// skip help menu
}
else
{
configuration.HelpRequested = true;
Expand Down

0 comments on commit 7715e56

Please sign in to comment.