Created
September 20, 2016 13:29
-
-
Save robgha01/bc7ff1a21f18183ade7943819f7ec477 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using Cake.Core; | |
using Cake.Core.Annotations; | |
using JetBrains.Annotations; | |
/// <summary> | |
/// NuGetPackSettings extensions. | |
/// </summary> | |
public static class CakeCoreExtensions | |
{ | |
/// <summary> | |
/// The get cake options. | |
/// </summary> | |
/// <param name="context"> | |
/// The context. | |
/// </param> | |
/// <returns> | |
/// A <see cref="IEnumerable{KeyValuePair}"/> containing | |
/// the parsed cake arguments. | |
/// </returns> | |
[CakeMethodAlias] | |
[CakeNamespaceImport("BlueLeet.Build.Extensions")] | |
[UsedImplicitly] | |
public static IEnumerable<KeyValuePair<string, string>> GetCakeOptions(this ICakeContext context) | |
{ | |
var result = new Dictionary<string, string>(); | |
var args = Environment.GetCommandLineArgs().Skip(1).ToList(); | |
// Include the script argument. | |
result.Add("-script", args[0]); | |
// Include the rest of the arguments. | |
foreach (var arg in args.Skip(1).Where(x => x.SingleOrDefault(c => c == '=') != default(char)).Select(x => x.Split('='))) | |
{ | |
result.Add(arg[0], arg[1]); | |
} | |
return result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The output is this.