Getting started with script commands
Developers spend a lot of time in small, repetitive tasks: opening the same pages, running the same commands, copying the same values. Script commands let you turn any script into a command you can run from Vectra.
What can Vectra do with scripts?
A script command is a file with a few comment lines at the top that describe it. Vectra reads those lines and turns the script into a command with a title, an icon and optional arguments.
Let's take a look at a small but useful script. Checking pull requests on a busy project usually goes like this:
Open your browser
Click in the search bar
Type the repository address
Load the page
Open the pull requests tab
With a script command, it is a single keystroke:
#!/bin/bash
# Required parameters:
# @vectra.schemaVersion 1
# @vectra.title Open Pull Requests
# @vectra.mode silent
# @vectra.icon ๐
# Optional parameters:
# @vectra.packageName Developer Utils
open "https://git.example.com/acme/app/pulls"So far, so good!
Let's go further and show the open pull requests right in Vectra, using the inline mode and a refresh interval.
#!/usr/bin/env ruby
# @vectra.schemaVersion 1
# @vectra.title Open Pull Requests
# @vectra.mode inline
# @vectra.refreshTime 5m
require "json"
require "net/http"
uri = URI("https://git.example.com/api/repos/acme/app/pulls")
pulls = JSON.parse(Net::HTTP.get(uri))
puts "#{pulls.size} open ยท oldest #{pulls.last["age"]}"The
refreshTimeparameter tells Vectra to rerun the script every five minutes.The
inlinemode prints the first line of output right in the root search.
Let's wrap up
By spending a few minutes putting together scripts for your common workflows, you can make your day noticeably smoother. Browse the community repository for more examples, and share your own.