From bc80e2ad38fdb6c18ca913a0c3038066152604da Mon Sep 17 00:00:00 2001 From: pomdtr Date: Mon, 12 Feb 2024 14:50:05 +0100 Subject: [PATCH] update default config --- internal/cli/embed/extension.py | 57 ----------------------------- internal/cli/embed/extension.sh | 56 ---------------------------- internal/cli/embed/extension.ts | 46 ----------------------- internal/cli/embed/sunbeam.json | 27 +++++++++++--- internal/schemas/action.schema.json | 2 +- 5 files changed, 22 insertions(+), 166 deletions(-) delete mode 100644 internal/cli/embed/extension.py delete mode 100644 internal/cli/embed/extension.sh delete mode 100755 internal/cli/embed/extension.ts diff --git a/internal/cli/embed/extension.py b/internal/cli/embed/extension.py deleted file mode 100644 index 3edb9ef5..00000000 --- a/internal/cli/embed/extension.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import json - -if len(sys.argv) == 1: - manifest = { - "title": "My Extension", - "description": "This is my extension", - "items": [ - { - "title": "Hi Mom!", - "command": "hi", - "params": { - "name": "Mom" - } - }, - { - "command": "hi", - } - ], - "commands": [ - { - "name": "hi", - "title": "Say Hi", - "mode": "detail", - "params": [ - { - "name": "name", - "title": "Name", - "type": "text" - } - ] - } - ] - } - print(json.dumps(manifest)) - sys.exit(0) - -payload = json.loads(sys.argv[1]) - -if payload["command"] == "hi": - name = payload["params"]["name"] - detail = { - "text": f"Hi {name}!", - "actions": [ - { - "title": "Copy Name", - "type": "copy", - "text": name - } - ] - } - print(json.dumps(detail)) -else: - print("Unknown command") - sys.exit(1) diff --git a/internal/cli/embed/extension.sh b/internal/cli/embed/extension.sh deleted file mode 100644 index cec0ea60..00000000 --- a/internal/cli/embed/extension.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh - -if [ "$#" -eq 0 ]; then - jq -n '{ - title: "My Extension", - description: "This is my extension", - items: [ - { - title: "Hi Mom!", - command: "hi", - params: { - name: "World" - } - }, - { - command: "hi", - } - ], - commands: [ - { - name: "hi", - title: "Say Hi", - mode: "detail", - params: [ - { - name: "name", - title: "Name", - type: "text" - } - ] - } - ] - }' - exit 0 -fi - -payload="$1" - -COMMAND=$(echo "$payload" | jq -r '.command') -if [ "$COMMAND" = "hi" ]; then - name="$(echo "$payload" | jq -r '.params.name')" - # shellcheck disable=SC2016 - jq -n --arg name "$name" '{ - text: "Hi \($name)!", - actions: [ - { - title: "Copy Name", - type: "copy", - text: $name - } - ] - }' -else - echo "Unknown command: $COMMAND" >&2 - exit 1 -fi diff --git a/internal/cli/embed/extension.ts b/internal/cli/embed/extension.ts deleted file mode 100755 index 8c1050b5..00000000 --- a/internal/cli/embed/extension.ts +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env -S deno run -A - -import * as sunbeam from "https://deno.land/x/sunbeam/mod.ts"; - -const manifest = { - title: "My Extension", - description: "This is my extension", - commands: [ - { - name: "hi", - title: "Say Hi", - mode: "detail", - params: [ - { - name: "name", - title: "Name", - type: "text", - }, - ], - }, - ], -} as const satisfies sunbeam.Manifest; - -if (Deno.args.length == 0) { - console.log(JSON.stringify(manifest)); - Deno.exit(0); -} - -const payload: sunbeam.Payload = JSON.parse(Deno.args[0]); -if (payload.command == "hi") { - const name = payload.params.name; - const detail: sunbeam.Detail = { - text: `Hi ${name}!`, - actions: [ - { - title: "Copy Name", - type: "copy", - text: name, - }, - ], - }; - console.log(JSON.stringify(detail)); -} else { - console.error(`Unknown command: ${payload.command}`); - Deno.exit(1); -} diff --git a/internal/cli/embed/sunbeam.json b/internal/cli/embed/sunbeam.json index 6f038aba..b1912b85 100644 --- a/internal/cli/embed/sunbeam.json +++ b/internal/cli/embed/sunbeam.json @@ -1,15 +1,30 @@ { - "$schema": "https://raw.githubusercontent.com/pomdtr/sunbeam/main/internal/schemas/config.schema.json", - "oneliners": [ + "$schema": "https://raw.githubusercontent.com/pomdtr/sunbeam/v2/internal/schemas/config.schema.json", + "root": [ + { + "title": "Edit Sunbeam Config", + "extension": "std", + "command": "edit", + "params": { + "path": "~/.config/sunbeam/sunbeam.json" + }, + "reload": true + }, { "title": "Open Sunbeam Docs", - "command": "sunbeam open https://sunbeam.sh/docs", - "exit": true + "extension": "std", + "command": "open", + "params": { + "url": "https://sunbeam.sh/docs" + } }, { "title": "Open Sunbeam Repository", - "command": "sunbeam open https://github.com/pomdtr/sunbeam", - "exit": true + "extension": "std", + "command": "open", + "params": { + "url": "https://github.com/pomdtr/sunbeam" + } } ] } diff --git a/internal/schemas/action.schema.json b/internal/schemas/action.schema.json index bf9d6702..653d72e5 100644 --- a/internal/schemas/action.schema.json +++ b/internal/schemas/action.schema.json @@ -8,7 +8,7 @@ "title": { "type": "string" }, - "key": { + "extension": { "type": "string" }, "command": {