Using the command help subsystem in OpenWrap

Documentation in a command-line tool is important. My latest push (as of a few minutes ago) implements a much improved get-help command. This should let you discover a lot of the functionality of OpenWrap without needing my blog posts.

Updating OpenWrap

I assume that you’re using the sources to run OpenWrap. Now is time to update your local copy with the latest changes, rebuild and reinstall. Difficult? We shall see.

To update, you simply issue a standard git command.

<div><b>PS C:\src\openwrap></b><i> git pull origin master</i></div>

Then, you need to rebuild OpenWrap. As OpenWrap uses OpenWrap to build itself, it’s pretty straightforward.

<div><b>PS C:\src\openwrap></b><i> o build-wrap</i></div>

That should produce a package in your current directory, all ready for update, which we can also do in one go.

<div><b>PS C:\src\openwrap></b><i> o update-wrap</i></div>

Getting a list of commands

As I’ve hinted several times before, commands are just one of the many things you can package in an OpenWrap package. They’re just plain old csharp code, which enables plenty of interesting scenarios I’ll talk about in a follow-up post.

So let’s see what we now have in our help system.

<div><b>PS C:\src\openwrap></b><i> o get-help</i></div>
# OpenWrap v1.0.0.0 ['C:\src\openwrap\wraps\_cache\openwrap-\bin-net35\OpenWrap.dll']

List of available commands

wrap update:
        Updates packages to their latest versions in local repositories.

Note that I’ve removed most of the content so this blog entry doesn’t get too big. What if you want help on a specific command, such as the clean-wrap command?

<div><b>PS C:\src\openwrap></b><i> o get-help clean-wrap</i></div>
# OpenWrap v1.0.0.0 ['C:\src\openwrap\wraps\_cache\openwrap-\bin-net35\OpenWrap.dll']

        Removes packages no longer in use in the local repositories.

        clean-wrap [[-System] <Boolean>] [[-Project] <Boolean>] [[-Name] <String>]

        -System <Boolean>
                Limits the cleaning to the system repository.

        -Project <Boolean>
                Limits the cleaning to the project repository.

        -Name <String>
                Specifies the name of the package for which to remove unused versions. If omitted, the clean will affect all packages.

There you go, now there is no excuse not to know commands by heart. And if you want to help translate those commands in your native language, I’m happy to take pull requests and Contributor License Agreements!

Later in the week we’ll see how easy it is for you to package your own commands to be deployed alongside your package. If you feel investigative, you can have a look at the source code for existing commands.


Creating your own OpenWrap repository on a file-share

I’m feeling in a blogging mood. There are so many things that are cool in OpenWrap that you can expect quite a bit of content in the next few days.

One of the features we have in OpenWrap, and have had for a while, is using a simple file share as a remote repository.

From a command line, add a remote repository by providing a name and a path. I’ll do that a mythical server I’ll call cherenkov.

<div><b>PS C:\src\demo></b><i> o add-remote corp file://cherenkov/c$/tmp/remoterepo/</i></div>
# OpenWrap v1.0.0.0 ['C:\src\demo\wraps\_cache\openwrap-\bin-net35\OpenWrap.dll']
Remote repository 'corp' added.

Note that I could’ve created a local repository (one on my hard drive) by using file:///c:/tmp/remoterepo/ instead.

You can now publish packages. I’ll be cheeky and reuse a package I downloaded from NuPack that got converted automatically in the OpenWrap format, which I showed you how to do in one of my previous posts.

<div><b>PS C:\src></b><i> o publish-wrap corp C:\users\sebastien.lambla\appdata\local\openwrap\wraps\Castle.Core-2.5.1.wrap</i></div>
# OpenWrap v1.0.0.0 ['C:\Users\sebastien.lambla\AppData\Local\OpenWrap\wraps\_cache\openwrap-\bin-net35\OpenWrap.dll']
Publishing package 'Castle.Core-2.5.1.wrap' to 'corp'

And just to make sure, let’s go and see what is now in our remote package.

<div><b>PS C:\src></b><i> o list-wrap -remote corp</i></div>
# OpenWrap v1.0.0.0 ['C:\Users\sebastien.lambla\AppData\Local\OpenWrap\wraps\_cache\openwrap-\bin-net35\OpenWrap.dll']
 - Castle.Core
   Versions: 2.5.1

Job done.


Using NuPack as a package repository in OpenWrap

NuPack came out a short while ago. While NuPack is only a subset of what OpenWrap was built to solve, a lot of libraries have already been added to their repositories, probably for the sole reason that it’s Microsoft and some people get excited about them doing anything having to do with Visual Studio.

But in the OpenWrap team, we think that packages are good, that’s why we’ve worked hard on our system for so many months. And we think you should, as a dedicated OpenWrap users, be able to import those packages until such a time the world adopt OpenWrap as the main way to deliver dependencies to you.

So you can do this now. At a command line, add nupack as a repository through the usual remote command.

<div><b>PS C:\src\demo></b><i> o add-remote nu nupack://</i></div>
# OpenWrap v1.0.0.0 ['C:\src\demo\wraps\_cache\openwrap-\bin-net35\OpenWrap.dll']
Remote repository 'nu' added.

From now on, any nupack will be downloaded and converted to the OpenWrap native format and be usable as usual in OpenWrap. Note that we only support things that do not have dependencies on PowerShell, so while you get command support out of the box with OpenWrap packages, we will do nothing with the PowerShell scripts at all.

You can query packages on that new server using the list-wrap –query command.

<div><b>PS C:\src\demo></b><i> o list-wrap -query *castle* -remote nu</i></div>
# OpenWrap v1.0.0.0 ['C:\src\demo\wraps\_cache\openwrap-\bin-net35\OpenWrap.dll']
 - Castle.Components.Validator
   Versions: 1.1.0
 - Castle.Core-log4net
   Versions: 2.5.1
 - Castle.Core-NLog
   Versions: 2.5.1
 - Castle.Core
   Versions: 1.1.0, 1.2.0, 2.5.1
 - Castle.DynamicProxy
   Versions: 2.1.0, 2.2.0
 - Castle.Windsor-log4net
   Versions: 2.5.1
 - Castle.Windsor-NLog
   Versions: 2.5.1
 - Castle.Windsor
   Versions: 2.1.1, 2.5.1
 - SNAP.CastleWindsor
   Versions: 1.0

And add one to the package, say the latest castle.core version:

<div><b>PS C:\src\demo></b><i> o add-wrap castle.core</i></div>
# OpenWrap v1.0.0.0 ['C:\src\demo\wraps\_cache\openwrap-\bin-net35\OpenWrap.dll']
Wrap descriptor found.
Project repository present.
Dependency added to descriptor.
Copying 'Castle.Core-2.5.1' from 'nu' to 'System repository'
Copying 'Castle.Core-2.5.1' from 'nu' to 'Project repository'
Making sure the cache is up-to-date...

And you’re done. On a side-note, the NuPack project will shift to the horrendous OData protocol, but provided they don’t break the examples they’ve shown of what atrocities introducing the EDM will do to their xml documents, we already support that too.