Skip to content

pumlhorse/pumlhorse-vscode

Repository files navigation

Pumlhorse Visual Studio Code extension

Pumlhorse is a scripting language with a simple, highly readable syntax. It can be used for automated testing, workflows, scripting utilities, and much more. More information is available on the Pumlhorse site.

Commands

Access the Command Palette by pressing the beaker icon in the lower left or by using the shortcut ctrl+alt+p p. This menu lets you:

  • Run the current file (ctrl+alt+p c)
  • Run all files in the workspace (ctrl+alt+p a)
  • Run a profile (ctrl+alt+p o)
  • Set the current profile

Running Scripts

When you run a script, the output will show in the Pumlhorse console.

In addition to the Command Palette, you can run a single file with the "play" button on the top right of the file editor.

You can also right-click a file or folder and choose "Run in Pumlhorse"

Running Profiles

Profiles allow you to run complex configurations in one go. For instance, you may have a set of scripts you want to run all at the same time. You can create a profile that includes those scripts.

Another common situation is using context files to extract environmental variables from the script. This allows you to have a single script that can be run in multiple environments. In this case, you can create a profile that uses those context files.

Sample Scripts

Try these scripts to get a feel for what Pumlhorse can do.

Print the latest version of Pumlhorse

name: Find the latest version of Pumlhorse
steps:
  - response = http.get:
      url: https://api.github.com/repos/pumlhorse/pumlhorse/contents/package.json
      headers:
        Accept: application/vnd.github.v3+json
  - http.isOk: $response # Ensure we got back a 200
  - decoded = convertFromBase64: $response.json.content
  - packageData = fromJson: $decoded
  - log: Current version of Pumlhorse is $packageData.version
functions:
  convertFromBase64:
    - input
    - return new Buffer(input, 'base64').toString('utf-8')

Print OS information

name: Print OS information
steps:
  # Log OS information using the Node 'os' module
  - osMod = import: os
  - log: HOSTNAME: $osMod.hostname()
  - log: RUNNING
  - log: OPERATING SYSTEM: $osMod.type() $osMod.arch()
  - log: CPU CORES: $osMod.cpus().length
  - log: TOTAL MEMORY: ${ osMod.totalmem() / 1000000 } MB

Check whether it's the weekend

name: Check if it's the weekend
functions:
  getTodaysDate:
    - return new Date().getDay()
steps:
  - dayOfWeek = getTodaysDate
  - if:
      value: ${ dayOfWeek == 5 }
      is true:
        - log: Congratulations, today is Friday!
      is false:
        - if:
            value: ${ dayOfWeek == 6 || dayOfWeek == 0}
            is true:
              - log: Congratulations, it's the weekend!
            is false:
              - log: Sorry, it's still not the weekend... 

Feedback

I am very interested in any feedback on this extension or Pumlhorse in general. Please feel free to submit an issue on Github.