forked from ransagy/NuKeeper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
56 lines (48 loc) · 1.64 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using McMaster.Extensions.CommandLineUtils;
using NuKeeper.Commands;
[assembly: InternalsVisibleTo("NuKeeper.Tests")]
#pragma warning disable CA1822
namespace NuKeeper
{
[Command(
Name = "NuKeeper",
FullName = "Automagically update NuGet packages in .NET projects.")]
[VersionOptionFromMember(MemberName = nameof(GetVersion))]
[Subcommand(typeof(InspectCommand))]
[Subcommand(typeof(UpdateCommand))]
[Subcommand(typeof(RepositoryCommand))]
[Subcommand(typeof(OrganisationCommand))]
[Subcommand(typeof(GlobalCommand))]
public class Program
{
public static int Main(string[] args)
{
var container = ContainerRegistration.Init();
var app = new CommandLineApplication<Program> { ThrowOnUnexpectedArgument = false };
app.Conventions.UseDefaultConventions().UseConstructorInjection(container);
try
{
return app.Execute(args);
}
catch (CommandParsingException cpe)
{
Console.WriteLine(cpe.Message);
return -1;
}
}
// ReSharper disable once UnusedMember.Global
protected int OnExecute(CommandLineApplication app)
{
// this shows help even if the --help option isn't specified
app.ShowHelp();
return 1;
}
private static string GetVersion() => typeof(Program)
.Assembly
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
.InformationalVersion;
}
}