codeflood logo

Revolver 3.1 Released

Earlier this week, I released Revolver 3.1. This was a smaller release, but still has some interesting features. For full details, check out the Revolver 3.1 Release on GitHub.

Custom Command Names

The main feature of this release was about command binding. In previous releases, when binding a custom command, one had to specify the name of the command to bind to. But the Command attribute allows specifying the command name. Internally, this is how Revolver does the initial binding of the core commands. So in Revolver 3.1, if your custom command includes the Command attribute, Revolver will use the command name from the attribute if a command name is not provided to the bind command. Let's take a look at that in action. Let's say we have the following custom command:

namespace CustomCommands
{
    [Command("myc")]
    public class MyCommand : BaseCommand
    {
        public override CommandResult Run()
        {
            return new CommandResult(CommandStatus.Success, "blah blah");
        }

        public override string Description()
        {
            return "My custom command";
        }

        public override void Help(HelpDetails details)
        {
        }
    }
}

To bind it using the command name provided in the attribute (myc), just pass the full class name to the bind command.

bind CustomCommands.MyCommand,CustomCommands

I can still bind it to a different name if I like, by providing the command name to the bind command:

bind othermyc CustomCommands.MyCommand,CustomCommands

Alias Command

There was also a problem with aliases which where introduced in Revolver 3.0. The problem arose from the parser, which only allowed a single instance of the same named parameter to be specified. For example, the following alias could not be created due to the double -a parameter:

# Don't do this, it won't work.
bind -a myalias ls -a

To overcome this limitation, aliases are now managed through a new dedicated alias command. This new command doesn't include any named parameters, so you can use whatever parameters you need to. Here's how we'd create that same alias in Revolver 3.1 with the new alias command.

alias myalias ls -a

And to remove the alias, just leave the command part off:

# This will remove the alias
alias myalias

With this change, the bind command no longer takes care of aliases, so you cannot use it to create them.

End of support for Sitecore 6.x

This will also be the last Revolver release to support Sitecore versions 6.x. To be honest, it was a bit of a pride thing for me to be able to support so many different Sitecore versions with a single code base, from Sitecore 6.4 to Sitecore 8.2 (plus the next version, wink, wink). But supporting so many different versions takes time that I would prefer to spend on making Revolver better. So why not drop support for the 3 to 5 year old versions? I think it's good practise for any Sitecore module to support the current and previous major versions. More than that and the effort required to maintain those older versions can start to outweight the value of having those versions supported, for what I hope is a very small audience.

Comments

Leave a comment

All fields are required.