To get started with NYoSh, we recommend that you follow the following steps.
- Download and install the NYoSh Workbench.
- Start the NYoSh Workbench [start the detailed tutorial below from this point, in the following you will learn how to:]
- Create a Solution,
- Create a model,
- Import the GobyWeb language (Command L on mac)
- Create an instance of a GobyWeb concept
- Learn about Undo/Redo
- Start editing the concept
- Learn about auto-completion
- Learn about intentions
Detailed Tutorial starts here:
After the application has started, you should see the following window:
- Click on the Create New Project button, you should see the following dialog:
- Configure the project as a Solution project. Solutions store code written in the NYoSh languages. Adjust the project and/or solution name and press OK. The workbench will open and show the following content:
- (This step is optional, try it the first time to familiarize yourself with the workbench. Routinely, it is easier to use the import language feature, shown below). The solution is created empty. In order to add code to this solution, you first need to define the set of languages that the code will be expressed in. Right click on the “New Solution” text (upper-left in the above snapshot, immediately under Project2). Choose option 1 “Model properties” in the popup (see below)
- (This step is also optional.) The following Solution properties dialog will be shown. Locate the ‘+’ button on the lower left corner of the dialog and add baseLanguage as shown in the snapshot below:
- (This step is also optional.) Continue by adding the NYoSh dependencies:
- (This step is also optional.) Use the same mechanism to locate the GobyWeb dependencies and add it. You should get the following correct set of dependencies:
- (This step is also optional.) Switch to the “Used Languages” tab and add languages as follow:
- Also add the org.campagnelab.gobyweb language to get the following set of used languages:
The Model properties dialog is very useful to add new languages to the solution so that you can code in these languages. When using MPS, it is a good idea to familiarize yourself with this dialog. User interfaces tend to be very consistent across MPS, and the tricks you have learned when adding dependencies and languages will come handy in many contexts. The above steps are not optional because the workbench can determine which set of languages are used. We will show how to do this with the import language feature below.
- Next, we need to create a model inside the solution. In the context of MPS, a model contains a set of concepts from a set of used languages. What this means is that the languages we declared using will now be available to write code. The code will be written as instances of concepts from the languages. These concepts will be stored in an MPS model.
- Create a model by right clicking on the solution and choosing New->Model.
- When the model creation dialog appears (see below), name the model and click OK
- Now that you have configured the languages, you can create concepts of these languages in the model. Right-click on the model name and browse to the type of concept that you wish to create. In this example, we will create a GobyWeb resource artifact installation script.
- After you created the concept, your workbench will look like the following (arrows and text have been added):
- Edit the id of the resource plugin. You can choose anything here, but this will need to match the id of a GobyWeb plugin in your plugin repository. The GobyWeb language will use the ID, together with the location/path of the plugin system to deploy the compiled NYoSh script to the plugin folder. To change the ID, place your cursor into the red <no pluginId> text and start typing. You can similarly
- Typing directly in <no pluginSystem> will not work because the location is not a text field. First press return to create an instance of a pluginSystem and you will then be able to enter the path of the system.
In MPS, the ENTER key is used to create and insert new concepts. You can remove a concept by pressing the DELETE key when the cursor is located on top of the concept. Try this with the plugin system instance (ENTER to create the concept, DELETE to remove it, ENTER to create it again). Note that MPS supports undo out of the box. See Undo/Redo under the Edit menu: