Skip to content

Releases: cake-contrib/Cake.ArgumentBinder

3.0.0 - Targeting .NET 6 and Cake 3.0

21 Nov 22:33
Compare
Choose a tag to compare

This release is nothing more than having Cake.ArgumentBinder target .NET 6 and Cake.Core 3.0.0. This means one should no longer get a warning if using Cake v3 and newer when using Cake.ArgumentBinder.

No functionality has changed.

Although .NET 7 is technically supported by Cake V3, I opted not to multi-target .NET 7 yet, as first I need to figure out how best to go about doing that (and hopefully I figure it out before .NET 7 goes end-of-life in a year).

Grab the NuGet package from your favorite NuGet package manager.

2.0.0 - Targeting .NET Core 3.1 and Cake 2.0

21 Nov 21:37
Compare
Choose a tag to compare

This release is nothing more than having Cake.ArgumentBinder target .NET Core 3.1 and Cake.Core 2.0.0. This means one should no longer get a warning if using Cake v2 and newer when using Cake.ArgumentBinder.

No functionality has changed.

Although .NET 5 is technically supported by Cake V2, I opted not to multi-target .NET 5, as it is no longer supported by Microsoft.

Grab the NuGet package from your favorite NuGet package manager.

1.0.0 - Retagging for new versioning scheme

21 Nov 18:38
Compare
Choose a tag to compare

This release is nothing more than a re-tag of the previous release to be more in-line with the new versioning scheme.

I've been thinking for a while on how I want to make it obvious which version of Cake Cake.ArgumentBinder depends on. What I came up with is the following scheme for versioning that we'll do going forward:

  • The major version (x in x.y.z) is the version of cake the library was compiled against. For example, if Cake.ArgumentBinder has a dependency on Cake version 2.0.0, the Cake.ArgumentBinder's version would be 2.y.z.
  • The minor version (y in x.y.z) will be incremented when a new feature gets added.
  • The patch (z in x.y.z) will be incremented when a bug fix happens.
  • We'll try to keep breaking backwards compatibility to a minimum, and only when a new major version of Cake is released.

Soon, 2.0.0 and 3.0.0 of this library will be released, stay tuned!

0.6.0 - Binding from Environment Variables!

22 May 21:04
Compare
Choose a tag to compare

With this release, it is now possible to specify the source of the argument to bind from. Up until now, one could only get a value from an argument via the command line. However, as of this release, one can now get the value of an argument from an environment variable as well!

There is now an "ArgumentSource" property that can be passed in when constructing an ArgumentBinder attribute. There are 4 choices:

  • CommandLine (default) - The value comes from a command-line argument.
  • EnvironmentVariable - The value comes from an environment variable.
  • CommandLineThenEnvironmentVariable - The value first comes from the command-line, but falls back to an environment variable if a command-line argument of the given name is not specified.
  • EnvironmentVariableThenCommandLine - The value first comes from an environment variable, but falls back to the command line if an environment variable of the given name is not specified.

Possible Breaking Change:

Another important thing to note is if anyone referenced the base classes (e.g. BaseBooleanAttribute), these classes have been removed an all functionality has been moved to the "ArgumentAttribute" classes instead (e.g. BooleanArgumentAttribute). The reason for this is was the original thought behind these classes was we could have our BooleanArgumentAttribute, but we could then have a BooleanEnvironmentVariableAttribute, both of which would inherit from this base class. However, once the idea of having a command line then environment variable class also came up, that becomes a lot of combinatorial explosions with the number of child classes we need to create (4 per type!). Rather, it was decided to instead add a property, thus making it easier to add even more sources in the future, should the need arise.

Downloads

Get the NuGet package from here: https://www.nuget.org/packages/Cake.ArgumentBinder/0.6.0

0.5.0 - Enum Binding!

11 Apr 20:41
Compare
Choose a tag to compare

With 0.5.0, we released an EnumArgumentAttribute. This allows one to limit argument choices to a specific enum. In addition, printing out the description includes all the values within an enum. We also allow parsing an enum while ignoring casing.

Any enum can be used as long as the following rules are, well, followed:

  • The enum must contain at least 1 value within it.
  • If the Required attribute is set to false on the attribute, the enum must have a value set to 0. 0 is the default value for an enum, and its the only way we can define a default enum value with Attribute objects.
  • If IgnoreCase is set to true, but there can not be 2 or enum values that, when casing is ignored, match.

Please see our tests for examples on how to use the Enum Binder.

You can see the latest NuGet here: https://www.nuget.org/packages/Cake.ArgumentBinder/0.5.0

0.4.0 - FilePath and DirectoryPath bind types

03 Apr 18:00
Compare
Choose a tag to compare

Downloads

Release Notes

FilePathArgumentAttribute and DirectoryPathArgumentAttribute

In this release, more types can be bounded to; specifically FilePath and DirectoryPath. This can be done with the FilePathArgument and DirectoryPathArgument respectively.

The main advantage of using these over a StringArgument is they contain a property called MustExist. For example, if you bind "c:\somewhere.txt" to a property binded to a FilePath, and it does not exist, the cake process will exit with an error. This way, you no longer need to check to see if a file or directory exists in your tasks, just have it setup in your config class.

An example, taken from our integration tests:

        public class FilePathBind
        {
            // ---------------- Fields ----------------

            internal const string RequiredArgName = "file_required";
            private const string requiredArgDescription = "A Required file";

            internal const string OptionalArgName = "file_optional";
            private const string optionalArgDescription = "An optional file";
            internal const string DefaultValue = "Hello";

            internal const string NullArgName = "file_nullarg";
            private const string nullArgDescription = "A file whose default value is null";
            internal const string NullDefaultValue = null;

            internal const string MustExistArgName = "file_mustexist";
            private const string mustExistArgDescription = "Must exist optional file";

            // ---------------- Properties ----------------

            [FilePathArgument(
                RequiredArgName,
                Description = requiredArgDescription,
                HasSecretValue = false,
                Required = true,
                MustExist = false
            )]
            public FilePath RequiredArg { get; set; }

            [FilePathArgument(
                OptionalArgName,
                Description = optionalArgDescription,
                HasSecretValue = false,
                DefaultValue = DefaultValue,
                Required = false,
                MustExist = false
            )]
            public FilePath OptionalArg { get; set; }

            [FilePathArgument(
                NullArgName,
                Description = nullArgDescription,
                HasSecretValue = false,
                DefaultValue = NullDefaultValue,
                Required = false,
                MustExist = false
            )]
            public FilePath NullDefaultArg { get; set; }

            [FilePathArgument(
                MustExistArgName,
                Description = mustExistArgDescription,
                HasSecretValue = false,
                Required = true,
                MustExist = true
            )]
            public FilePath FileMustExistArg { get; set; }

            // ---------------- Functions ----------------

            public override string ToString()
            {
                return ArgumentBinder.ConfigToStringHelper( this );
            }
        }

Hidden Value Changes

If a property is set to have its value hidden, the DefaultValue, Min, and Max value(s) will not appear when printing out a description. As usual, the ToString helper function will also hide the hidden value.

If a property is set to not have its value hidden, then "Value Hidden: false" no longer appears in the Description string. The reason why is this just seemed to take up too much space in the print out, and didn't provide any useful information.

Other fixes

  • If a Default value is null, we will not NRE when calling a description or ToString helper.
  • If a value is null, we will not NRE when calling a description or a ToString helper.

0.3.0 - Cake.Core Upgrade

08 Feb 02:21
Compare
Choose a tag to compare

This is a small release that updates our target Cake.Core to 1.0.0. No other changes were made.

0.2.3 - Cake.Core upgrade

31 Oct 20:01
Compare
Choose a tag to compare

This release is a small release that does the following:

  • Added CakeAliasCategory so Aliases shows up on the Cake website.
  • Upgraded Cake.Core to 0.38.5

Version 0.2.1

03 Jan 03:51
Compare
Choose a tag to compare

This is a release that only changes how things are packaged. Everything else should be the same as it was in version 0.2.0.

  • Use in nuspec
  • Include the XML document string.

Version 0.2.0

02 Jan 23:28
Compare
Choose a tag to compare

This release finally adds Cake Aliases, so we no longer need to call ArgumentBinder.Something all the time, we can use the Cake methods.

You can continue to call these functions if you want, but are no longer required to. The table below shows the old methods, and the new way to call them:

Original Function New Alias Function
ArgumentBinder.FromArguments CreateFromArguments
ArgumentBinder.ConfigToStringHelper ArgumentConfigToString
ArgumentBinder.GetDescription DescriptionFromArguments

DescriptionFromArguments is an extension of CakeTaskBuilder, not ICakeContext, so it can be called while creating a task.

The readme and examples have been updated to use the new functions.

Lastly, the package is now smaller, by only including the ArgumentBinder.dll and .pdb file instead of everything else.