diff --git a/Cake.ArgumentHelpers.sln b/Cake.ArgumentHelpers.sln new file mode 100644 index 0000000..9fc2d14 --- /dev/null +++ b/Cake.ArgumentHelpers.sln @@ -0,0 +1,27 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.13 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.ArgumentHelpers", "Cake.ArgumentHelpers\Cake.ArgumentHelpers.csproj", "{9C50A7C4-E00D-4851-8311-81135D062C77}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EA17B50A-988B-47C1-9840-DC7347D88259}" + ProjectSection(SolutionItems) = preProject + Package.nuspec = Package.nuspec + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9C50A7C4-E00D-4851-8311-81135D062C77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9C50A7C4-E00D-4851-8311-81135D062C77}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9C50A7C4-E00D-4851-8311-81135D062C77}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9C50A7C4-E00D-4851-8311-81135D062C77}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Cake.ArgumentHelpers/ArgumentOrEnvironmentVariableAlias.cs b/Cake.ArgumentHelpers/ArgumentOrEnvironmentVariableAlias.cs new file mode 100644 index 0000000..d74365d --- /dev/null +++ b/Cake.ArgumentHelpers/ArgumentOrEnvironmentVariableAlias.cs @@ -0,0 +1,21 @@ +using System; +using Cake.Core; +using Cake.Core.Annotations; +using Cake.Common; + +namespace Cake.ArgumentHelpers +{ + public static class ArgumentOrEnvironmentVariableAlias + { + /// + /// Get a bool variable from various script inputs: first via Argument, then falling back on EnvironmentVariable, finally falling back on a default. + /// + /// An optional prefix used to qualify the same variable name when present in EnvironmentVariable form (e.g., "MySetting" command-line argument vs. "MyTool_MySetting" environment variable). + /// Value found or default, first checked in command-line argument, then environment variable. + [CakeMethodAlias] + public static bool ArgumentOrEnvironmentVariable(this ICakeContext context, string name, string environmentNamePrefix, bool defaultValue) + { + return ArgumentAliases.Argument(context, name, EnvironmentAliases.EnvironmentVariable(context, (environmentNamePrefix ?? "") + name) ?? defaultValue.ToString()).Equals("true", StringComparison.OrdinalIgnoreCase); + } + } +} diff --git a/Cake.ArgumentHelpers/Cake.ArgumentHelpers.csproj b/Cake.ArgumentHelpers/Cake.ArgumentHelpers.csproj new file mode 100644 index 0000000..f536c7c --- /dev/null +++ b/Cake.ArgumentHelpers/Cake.ArgumentHelpers.csproj @@ -0,0 +1,58 @@ + + + + + Debug + AnyCPU + {9C50A7C4-E00D-4851-8311-81135D062C77} + Library + Properties + Cake.ArgumentHelpers + Cake.ArgumentHelpers + v4.5 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + bin\Release\Cake.ArgumentHelpers.xml + + + + ..\packages\Cake.Common.0.20.0\lib\net45\Cake.Common.dll + + + ..\packages\Cake.Core.0.20.0\lib\net45\Cake.Core.dll + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Cake.ArgumentHelpers/Properties/AssemblyInfo.cs b/Cake.ArgumentHelpers/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..af5f76e --- /dev/null +++ b/Cake.ArgumentHelpers/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Cake.ArgumentHelpers")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Cake.ArgumentHelpers")] +[assembly: AssemblyCopyright("Copyright 2017 © Adam Patridge")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("9c50a7c4-e00d-4851-8311-81135d062c77")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Cake.ArgumentHelpers/packages.config b/Cake.ArgumentHelpers/packages.config new file mode 100644 index 0000000..4d5d9e1 --- /dev/null +++ b/Cake.ArgumentHelpers/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Package.nuspec b/Package.nuspec new file mode 100644 index 0000000..a675ce7 --- /dev/null +++ b/Package.nuspec @@ -0,0 +1,24 @@ + + + + Cake.ArgumentHelpers + 0.0.3 + Adam Patridge + Adam Patridge + https://github.com/patridge/Cake.ArgumentHelpers/blob/master/LICENSE + https://github.com/patridge/Cake.ArgumentHelpers + false + Cake add-on trying to make it easier to handle various inputs from arguments and environment variable. + Initial release + Copyright (c) Adam Patridge 2017 + Cake Script Build + + + + + + + + + +