Skip to content

Commit

Permalink
simplify manifest API
Browse files Browse the repository at this point in the history
  • Loading branch information
pomdtr committed Jan 22, 2024
1 parent 8734b2f commit ac28eaa
Show file tree
Hide file tree
Showing 25 changed files with 70 additions and 136 deletions.
2 changes: 1 addition & 1 deletion extensions/bitwarden.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if [ $# -eq 0 ]; then
preferences: [
{
name: "session",
description: "Bitwarden Session",
title: "Bitwarden Session",
type: "string"
}
],
Expand Down
2 changes: 1 addition & 1 deletion extensions/brew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if [ $# -eq 0 ]; then
params: [
{
name: "package",
description: "Package Name",
title: "Package Name",
type: "string"
}
]
Expand Down
6 changes: 3 additions & 3 deletions extensions/deno-deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const manifest = {
preferences: [
{
name: "token",
description: "Access Token",
title: "Access Token",
type: "string",
},
],
Expand All @@ -29,14 +29,14 @@ const manifest = {
title: "List Deployments",
hidden: true,
mode: "filter",
params: [{ name: "project", description: "Project", type: "string" }],
params: [{ name: "project", title: "Project", type: "string" }],
},
{
name: "playground",
title: "View Playground",
hidden: true,
mode: "detail",
params: [{ name: "project", description: "Project", type: "string" }],
params: [{ name: "project", title: "Project", type: "string" }],
},
],
} as const satisfies sunbeam.Manifest;
Expand Down
2 changes: 1 addition & 1 deletion extensions/devdocs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if [ $# -eq 0 ]; then
title: "List Entries from Docset",
mode: "filter",
params: [
{ name: "slug", description: "Slug", type: "string" }
{ name: "slug", title: "Slug", type: "string" }
]
}
]
Expand Down
4 changes: 2 additions & 2 deletions extensions/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"preferences": [
{
"name": "show-hidden",
"description": "Show Hidden Files",
"title": "Show Hidden Files",
"type": "boolean",
"optional": True,
}
Expand All @@ -23,7 +23,7 @@
"params": [
{
"name": "dir",
"description": "Directory",
"title": "Directory",
"type": "string",
"optional": True,
},
Expand Down
20 changes: 10 additions & 10 deletions extensions/gists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const manifest = {
preferences: [
{
name: "token",
description: "GitHub Personal Access Token",
title: "GitHub Personal Access Token",
type: "string",
},
],
Expand All @@ -27,18 +27,18 @@ const manifest = {
params: [
{
name: "filename",
description: "Gist Filename",
title: "Gist Filename",
type: "string",
},
{
name: "description",
description: "Gist Description",
title: "Gist Description",
optional: true,
type: "string",
},
{
name: "public",
description: "Public",
title: "Public",
type: "boolean",
},
],
Expand All @@ -48,16 +48,16 @@ const manifest = {
title: "Browse Gist Files",
hidden: true,
mode: "filter",
params: [{ name: "id", description: "Gist ID", type: "string" }],
params: [{ name: "id", title: "Gist ID", type: "string" }],
},
{
name: "view",
title: "View Gist File",
hidden: true,
mode: "detail",
params: [
{ name: "id", description: "Gist ID", type: "string" },
{ name: "filename", description: "Filename", type: "string" },
{ name: "id", title: "Gist ID", type: "string" },
{ name: "filename", title: "Filename", type: "string" },
],
},
{
Expand All @@ -66,16 +66,16 @@ const manifest = {
hidden: true,
mode: "tty",
params: [
{ name: "id", description: "Gist ID", type: "string" },
{ name: "filename", description: "Filename", type: "string" },
{ name: "id", title: "Gist ID", type: "string" },
{ name: "filename", title: "Filename", type: "string" },
],
},
{
name: "delete",
hidden: true,
title: "Delete Gist",
mode: "silent",
params: [{ name: "id", description: "Gist ID", type: "string" }],
params: [{ name: "id", title: "Gist ID", type: "string" }],
},
],
} as const satisfies sunbeam.Manifest;
Expand Down
8 changes: 4 additions & 4 deletions extensions/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const manifest = {
preferences: [
{
name: "token",
description: "Personal Access Token",
title: "Personal Access Token",
type: "string",
},
],
Expand All @@ -27,7 +27,7 @@ const manifest = {
params: [
{
name: "repo",
description: "Repository Name",
title: "Repository Name",
type: "string",
},
],
Expand All @@ -40,7 +40,7 @@ const manifest = {
params: [
{
name: "repo",
description: "Repository Name",
title: "Repository Name",
type: "string",
},
],
Expand All @@ -53,7 +53,7 @@ const manifest = {
params: [
{
name: "repo",
description: "Repository Name",
title: "Repository Name",
type: "string",
},
],
Expand Down
2 changes: 1 addition & 1 deletion extensions/hackernews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const manifest = {
name: "browse",
title: "Show a feed",
mode: "filter",
params: [{ name: "topic", description: "Topic", type: "string" }],
params: [{ name: "topic", title: "Topic", type: "string" }],
},
],
} as const satisfies sunbeam.Manifest;
Expand Down
1 change: 1 addition & 0 deletions extensions/nixpkgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as sunbeam from "https://deno.land/x/sunbeam/mod.ts";

const manifest = {
title: "Nixpkgs Search",
description: "Search Nixpkgs packages",
commands: [
{
name: "search",
Expand Down
1 change: 1 addition & 0 deletions extensions/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as sunbeam from "https://deno.land/x/sunbeam/mod.ts";

const manifest: sunbeam.Manifest = {
title: "NPM Search",
description: "Search NPM packages",
commands: [
{
name: "search",
Expand Down
2 changes: 1 addition & 1 deletion extensions/raindrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const manifest = {
preferences: [
{
name: "token",
description: "Raindrop API Token",
title: "Raindrop API Token",
type: "string",
},
],
Expand Down
2 changes: 1 addition & 1 deletion extensions/rss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const manifest = {
params: [
{
name: "url",
description: "URL",
title: "URL",
type: "string",
},
],
Expand Down
2 changes: 1 addition & 1 deletion extensions/tailscale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const manifest = {
params: [
{
name: "ip",
description: "Device IP",
title: "Device IP",
type: "string",
},
],
Expand Down
2 changes: 1 addition & 1 deletion extensions/tldr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if [ $# -eq 0 ]; then
# each command can be called through the cli
commands: [
{ name: "list", mode: "filter", title: "Search Pages" },
{ name: "view", mode: "detail", hidden: true, title: "View page", params: [{ name: "page", type: "string", description: "page to show" }] },
{ name: "view", mode: "detail", hidden: true, title: "View page", params: [{ name: "page", type: "string", title: "Page to show" }] },
{ name: "update", mode: "silent", title: "Update cache" }
]
}'
Expand Down
8 changes: 4 additions & 4 deletions extensions/valtown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const manifest = {
preferences: [
{
name: "token",
description: "Access Token",
title: "Access Token",
type: "string",
},
],
Expand All @@ -19,7 +19,7 @@ const manifest = {
mode: "filter",
params: [{
name: "user",
description: "User",
title: "User",
optional: true,
type: "string",
}],
Expand All @@ -34,14 +34,14 @@ const manifest = {
name: "edit",
hidden: true,
mode: "tty",
params: [{ name: "id", description: "Val ID", type: "string" }],
params: [{ name: "id", title: "Val ID", type: "string" }],
},
{
title: "View Readme",
name: "readme",
hidden: true,
mode: "detail",
params: [{ name: "id", description: "Val ID", type: "string" }],
params: [{ name: "id", title: "Val ID", type: "string" }],
},
],
} as const satisfies sunbeam.Manifest;
Expand Down
6 changes: 3 additions & 3 deletions internal/cli/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ func NewSubCmdCustom(alias string, extension extensions.Extension, extensionConf
for _, input := range command.Params {
switch input.Type {
case sunbeam.InputString:
cmd.Flags().String(input.Name, "", input.Description)
cmd.Flags().String(input.Name, "", input.Title)
case sunbeam.InputBoolean:
cmd.Flags().Bool(input.Name, false, input.Description)
cmd.Flags().Bool(input.Name, false, input.Title)
case sunbeam.InputNumber:
cmd.Flags().Int(input.Name, 0, input.Description)
cmd.Flags().Int(input.Name, 0, input.Title)
}

if !input.Optional {
Expand Down
18 changes: 6 additions & 12 deletions internal/schemas/manifest.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,21 @@
"type": "object",
"required": [
"name",
"description",
"title",
"type"
],
"properties": {
"name": {
"type": "string"
},
"description": {
"title": {
"type": "string"
},
"type": {
"oneOf": [
{
"type": "string"
},
{
"type": "boolean"
},
{
"type": "number"
}
"enum": [
"string",
"boolean",
"number"
]
},
"optional": {
Expand Down
10 changes: 5 additions & 5 deletions internal/tui/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func NewTextField(input sunbeam.Input, secure bool) *TextField {
name: input.Name,
title: input.Name,
Model: ti,
placeholder: input.Description,
placeholder: input.Title,
}
}

Expand Down Expand Up @@ -140,11 +140,11 @@ func NewTextArea(input sunbeam.Input) Input {
}
}

ta.Placeholder = input.Description
ta.Placeholder = input.Title
ta.SetHeight(5)

return &TextArea{
title: input.Description,
title: input.Title,
name: input.Name,
Model: ta,
}
Expand Down Expand Up @@ -205,7 +205,7 @@ type Checkbox struct {
func NewCheckbox(param sunbeam.Input) *Checkbox {
checkbox := Checkbox{
name: param.Name,
title: param.Description,
title: param.Title,
}

if param.Default != nil {
Expand All @@ -214,7 +214,7 @@ func NewCheckbox(param sunbeam.Input) *Checkbox {
}
}

checkbox.label = param.Description
checkbox.label = param.Title

return &checkbox
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/sunbeam/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ const (
)

type Input struct {
Type InputType `json:"type"`
Name string `json:"name"`
Description string `json:"description"`
Optional bool `json:"optional,omitempty"`
Default any `json:"default,omitempty"`
Type InputType `json:"type"`
Name string `json:"name"`
Title string `json:"title"`
Optional bool `json:"optional,omitempty"`
Default any `json:"default,omitempty"`
}
Loading

0 comments on commit ac28eaa

Please sign in to comment.