-
Notifications
You must be signed in to change notification settings - Fork 0
Commanding system
Most of OpenWrap's functionality is available through a variety of commands.
You can get the list of commands at any time by reading the command help.
$ o get-help
The get-help command can also display help for a specific command.
$ o get-help verb-noun
Commands have a noun and a verb, similar to PowerShell commands, and take a bunch of input parameters.
When using the o.exe
shell, you can call a command using one of two notations.
$ o noun verb
$ o verb-noun
For example, to access the help for existing commands, both get-help
and help get
can be used.
The shell also supports partial naming. Provided only one name and verb are matching, the command can be typed as h g
or any other parts of the names.
Most commands also take input parameters, which have a name and a value. When using the shell, parameter names are prefixed with a single -
, and values are either a single value or a quoted string.
For example, the documentation for the add-wrap command is as follow.
add-wrap [-Name] <String> [[-Version] <String>] [-Anchored <Boolean>] [-Content <Boolean>] [-MaxVersion <String>] [-MinVersion <String>] [-NoDescriptorUpdate <Boolean>] [-Project <Boolean>] [-System <Boolean>]
Required parameters are the ones that are necessary for the command to execute. In the previous example, the Name
parameter is required.
Positioned parameters (like Name and Version above) are parameters that can be entered without specifying the name, in the correct order. In the previous example, the -Name
input name is a positioned parameter, enclosed in square brackets to denote it is optional.
In the add-wrap command, those two commands are equivalent.
$ o add-wrap -Name nhibernate
$ o add-wrap nhibernate
Optional parameters are not necessary for the command to execute. In the documentation, optional parameters are enclosed in square brackets, such as the [-Anchored <Boolean>]
.
Because commands are not tied to any execution environment, they can be executed in a multitude of hosts. One such host is MSBuild.
To enable executing commands in MSBuild, two tasks need to be included and one executed.
To include the MSBuild command, add the following import (making sure the path the assemblies is correct).
<UsingTask TaskName="OpenWrap.Build.InitializeOpenWrap" AssemblyFile="wraps\openwrap\bin-net35\OpenWrap.dll" />
<UsingTask TaskName="OpenWrap.Build.Tasks.RunCommand" AssemblyFile="wraps\openwrap\build\OpenWrap.Build.Tasks.dll" />
Once those two tasks are declared, the InitializeOpenWrap command needs to be included for OpenWrap to be able to resolve assemblies during build execution. You can put this in a target executed on start.
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5" InitialTargets="_Initialize">
<Target Name="_Initialize">
<InitializeOpenWrap CurrentDirectory="$(MSBuildProjectDirectory)\.." />
</Target>
</Project>
The CurrentDirectory parameter is used to declare the root of your project, usually where your package descriptor lives.
To execute a command, the RunComand
is used. For example, to execute the get-help
command, this is the msbuild file one would use.
<RunCommand
Verb="build"
Noun="wrap" />
The Noun and Verb attributes are the exact nouns and verbs defined for a command.
Parameters are passed by creating a property group for parameters and passing it to the Args
parameter.
For example, a publish command would be executed with the following snippet.
<PropertyGroup>
<PublishCommandArguments>
<Name>PackageName</Name>
<RemoteRepository>http://wraps.openwrap.org</RemoteRepository>
</PublishCommandArguments>
</PropertyGroup>
<RunCommand Noun="wrap" Verb="publish" Args="$(PublishCommandArguments)" />
The sub-properties in the PropertyGroup are passed to the command.
Warnings and errors from commands are being turned into MSBuild warnings and errors automatically.