Issue ACE-366 suggests we add a set of gogo shell commands to talk to the client API. As a first step I'd like to base these on the REST client API which introduces the concept of a "workspace" that you can manipulate. Once you have a workspace, various commands allow you to interact with it before you finally commit it back to the server.
This is not a gogo shell tutorial, it uses some concepts of that shell without explaining them here, so please refer to documentation for the shell if you're not familiar with that.
So far the commands are all fairly basic. This is on purpose. The basic commands can be used as building blocks for more complex ones, or scripts. Adding commands is easy too, they are just public methods on the Workspace
class.
Shell commands
There are only two real shell commands that we need. All the other "commands" operate on the workspace and will be explained below under 'Workspace commands'.
cw
- create workspace
Creates a workspace. You normally want to store such a workspace in a shell variable, so you can reference it.
w = (cw)
rw
- remove workspace
Removes a workspace that was previously created. It does not commit it or anything, so make sure you do that first if you want to persist your changes.
rw $w
Workspace commands
The workspace commands here all assume you've created a workspace called w
.
$w checkout
- checks out the workspace
Normally, when you create a workspace, it is checked out automatically. If however someone else committed an update afterwards, you can pull that into your workspace with this command.
$w commit
- commits the changes to the workspace
Commits any changes you made in the workspace.
$w la
- lists all artifacts
You can optionally specify a filter condition to limit the list.
$w ca
- creates an artifact
You can specify the artifact's name URL bsn version
.
You can also specify a map of attributes.
You can also specify a map of attributes and a map of tags.
$w la2f
- lists all artifact to feature associations
$w ca2f
- creates an artifact to feature association
You must at least specify a filter for the left hand side and right hand side, in which case a 1:1 cardinality is assumed.
You can also specify both the filters and cardinalities (and use N
as a placeholder for Integer.MAX_VALUE
).
$w lf
- lists all features
You can optionally specify a filter condition to limit the list.
$w cf
- creates a feature
You can specify a feature's name
.
You can also specify a map of attributes.
You can also specify a map of attributes and a map of tags.
$w df
- deletes a feature
$w la2f
- lists all feature to distribution associations
$w cf2d
- creates a feature to distribution association
You must at least specify a filter for the left hand side and right hand side, in which case a 1:1 cardinality is assumed.
You can also specify both the filters and cardinalities (and use N
as a placeholder for Integer.MAX_VALUE
).
$w la2f
- lists all distributions
You can optionally specify a filter condition to limit the list.
$w cd
- creates a distribution
You can specify a distribution's name
.
You can also specify a map of attributes.
You can also specify a map of attributes and a map of tags.
$w la2f
- lists all distribution to target associations
$w cd2t
- creates a distribution to target association
You must at least specify a filter for the left hand side and right hand side, in which case a 1:1 cardinality is assumed.
You can also specify both the filters and cardinalities (and use N
as a placeholder for Integer.MAX_VALUE
).
$w la2f
- lists all targets
You can optionally specify a filter condition to limit the list.
$w ct
- creates a target
You can specify a target's name
.
You can also specify a map of attributes.
You can also specify a map of attributes and a map of tags.
Examples
w = (cw) $w ca2f "(Bundle-SymbolicName=org.foo.*)" "(name=feature-1)" N 1 $w cf feature-1 $w cf2d "(name=feature-1)" "(name=distribution-1)" 1 1 $w cd distribution-1 $w cd2t "(name=distribution-1)" "(id=*)" 1 N $w commit
Creates a workspace, creates an association between any artifact whose BSN starts with "org.foo." and "feature-1". Links "feature-1" to "distribution-1" and finally assigns that distribution to any target.
w = (cw) each ($w la) { $args name }
Lists all the names of the artifacts in the workspace.