Skip to content

Commit

Permalink
fix guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
pomdtr committed Nov 6, 2023
1 parent efa39cf commit 793bb88
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions docs/developer-guide/guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,25 @@ Sunbam provides multiple helpers to make it easier to share sunbeam extensions,
- `sunbeam copy/paste`: copy/paste text from/to the clipboard

```sh
#! /bin/sh
#!/bin/sh

# fail on error
set -eu

if [ $# -eq 0 ]; then
sunbeam query -n '{
title: "Hello World!",
commands: [{
name: "say-hello",
type: "string",
required: true
title: "Say Hello",
mode: "detail"
}]
}'
exit 0
fi

COMMAND=(echo "$1" | jq -r '.command')
COMMAND=$(echo "$1" | jq -r '.command')
if [ "$COMMAND" = "say-hello" ]; then
sunbeam query -n { text: "Hello, World!" }
sunbeam query -n '{ text: "Hello, World!" }'
fi
```

Expand All @@ -60,26 +59,27 @@ Deno allows you to use any npm package by just importing it from a url. This mak
To make it easier to write extensions in deno, sunbeam provides a [npm package](https://www.npmjs.com/package/sunbeam-types) that provides types for validating the manifest and payloads.

```ts
#! /usr/bin/env -S deno run -A
#!/usr/bin/env -S deno run -A

// import the types
import type * as sunbeam from "npm:[email protected].16"
import type * as sunbeam from "npm:[email protected].18"

// import any npm package
// @deno-types="npm:@types/lodash"
import _ from "npm:lodash"

if (Deno.length == 0) {
if (Deno.args.length == 0) {
// if invoked without arguments, print the manifest
const manifest: sunbeam.Manifest = {
title: "Hello World!",
commands: [{
name: "say-hello",
type: "string",
required: true
title: "Say Hello",
mode: "detail",
}]
}

console.log(JSON.stringify(manifest))
Deno.exit(0)
}

Expand All @@ -88,11 +88,12 @@ const payload = JSON.parse(Deno.args[0]) as sunbeam.Payload

if (payload.command == "say-hello") {
const detail: sunbeam.Detail = {
text: _.uppercase("Hello, World!")
text: _.upperCase("Hello, World!")
}

console.log(JSON.stringify(detail))
}

```

A more complex typescript extension can be found [here](./typescript.md).

0 comments on commit 793bb88

Please sign in to comment.