Skip to content

Write a plugin

This adds a Describe command to the GCE instances list. It runs gcloud compute instances describe against the selected instance.

  1. Find where nuvem looks for the plugin file:

    Shell
    nuvem info

    The plugins: line names the path, for example ~/.config/nuvem/plugins.toml (not found).

  2. Create that file with one plugin:

    TOML
    version = 1
    [[plugins]]
    id = "describe"
    scope = "compute"
    key = "d"
    label = "Describe {name}"
    args = ["compute", "instances", "describe", "{name}", "--zone", "{zone}"]

    scope names the service. {name} and {zone} are filled from the selected row. Plugin file reference lists every field and the template fields each service has.

  3. Make sure that other users cannot write it. Use the path from step 1. On Linux, unless you set XDG_CONFIG_HOME, that is:

    Shell
    chmod o-w ~/.config/nuvem/plugins.toml

    On macOS:

    Shell
    chmod o-w ~/Library/Application\ Support/nuvem/plugins.toml
  4. Run nuvem info again. The line now reads (1 loaded). If it reads (0 loaded), the warning below it says what is wrong.

  5. Start nuvem, open GCE instances (g, then pick the service), and select an instance. Then either:

    • Press , and then d.
    • Press :, type describe, and press Enter.
  6. nuvem shows the exact command, for example:

    Text
    gcloud --configuration dev compute instances describe web-01 --zone europe-west1-b

    Press Enter to run it or Esc to cancel.

  7. To read what it printed, press : and choose Plugin output. See Plugin output.

The run appears in Home’s Recent operations list. To stop a run that does not end, press Ctrl-x.

To ask for a value the row does not have, add an input. This resizes a disk to a size you type:

TOML
[[plugins]]
id = "grow-disk"
scope = "disks"
key = "G"
label = "Grow {name} to {new_size}GB"
args = ["compute", "disks", "resize", "{name}", "--size", "{new_size}"]
[[plugins.inputs]]
name = "new_size"
type = "integer"
default = 200

See Typed inputs.

Add dangerous = true to a plugin that deletes or changes something you cannot undo. Its confirmation then asks you to type 1 before Enter runs it. The 1 is the number of resources the command acts on, which for a plugin is always one.

nuvem reads the plugin file once, at startup. After editing it, quit and start nuvem again.

nuvem is released under the MIT License. The source is on GitHub.

nuvem is an independent project, not affiliated with or endorsed by Google. Google Cloud is a trademark of Google LLC.