-
Notifications
You must be signed in to change notification settings - Fork 3
/
CmdArguments.cs
51 lines (42 loc) · 1.36 KB
/
CmdArguments.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
// Copyright (c) 2015 Abel Cheng <[email protected]>. Licensed under the MIT license.
// Repository: https://nupkgmerge.codeplex.com/
using System.Linq;
using System.Collections.Generic;
using CommandLine;
using CommandLine.Text;
namespace NuGetPackageMerge
{
class CmdArguments
{
[Option('p', "primary", Required = true, HelpText = "\tSpecifies the primary .nupkg file.")]
public string PrimaryNupkg { get; set; }
[Option('s', "second", Required = true, HelpText = "\tSpecifies the second .nupkg file.")]
public string SecondNupkg { get; set; }
[Option('o', "out", Required = true, HelpText = "\tSpecifies the output .nupkg filename.")]
public string OutputNupkg { get; set; }
[ParserState]
public IParserState LastParserState { get; set; }
[HelpOption]
public string GetUsage()
{
return HelpText.AutoBuild(this,
(HelpText current) => HelpText.DefaultParsingErrorsHandler(this, current));
}
public bool Parse(string[] args)
{
NormalizeArguments(args);
return Parser.Default.ParseArguments(args, this);
}
private static void NormalizeArguments(string[] args)
{
for (int i = 0; i < args.Length; i++)
{
if (args[i].StartsWith("/"))
args[i] = "-" + args[i].TrimStart('/');
if (args[i].StartsWith("-") && args[i].Length > 2)
if (args[i][1] != '-' && args[i][2] != '"')
args[i] = "-" + args[i];
}
}
}
}