Skip to content

Adding CRaSH commands

Or Cohen edited this page Jan 29, 2014 · 4 revisions

CRaSH is the embedded shell we use. Commands in CRaSH are currently groovy scripts. This might change in next versions of CRaSH, though.

Location

Commands are placed in mgmt/crash/src/main/resources/crash/commands/cloudius.

Developing

A command can be a simple groovy script or a class. We prefer using classes because we can add more metadata to them (i.e. description, help, man, etc.).

To learn how to write a command, please see http://www.crashub.org/reference.html#d5e519.

CRaSH related development notes

  • Besides the out variable which exists in the command context, there's also the unmatched variable as well. This variable contains all of the unmatched arguments from the command line.

OSv related command development

OSvCommand class

This class was created to provide shared functionality between commands. It contains methods to help with argument completion, "daemonization" and simple output column formatting.

login.groovy

CRaSH executes this script for each session. This is where the prompt is configured, where we simulate a "current working directory". All variables defined in this file will be available for commands. For example, getResolvedPath(somepath) Will return the correct resolved path, relative to the current working directory.