Skip to content

Commit

Permalink
Added support for dropdown in arguments (#32)
Browse files Browse the repository at this point in the history
Added support for dropdown in arguments
  • Loading branch information
pernielsentikaer authored Feb 23, 2024
1 parent 664e00c commit a43907a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 0.17

- Add dropdown type for arguments

## 0.16

- Add `Add Swift Support` command
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
"name": "raycast",
"displayName": "Raycast",
"description": "",
"version": "0.16.0",
"version": "0.17.0",
"engines": {
"vscode": "^1.67.0"
},
"publisher": "tonka3000",
"contributors": [
"pernielsentikaer"
],
"license": "MIT",
"categories": [
"Other"
Expand Down
10 changes: 8 additions & 2 deletions src/commands/addCommandArgument.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as vscode from "vscode";
import { ExtensionManager } from "../manager";
import { Argument, readManifestFile } from "../manifest";
import { Argument, ArgumentType, readManifestFile } from "../manifest";
import { ArgumentsTreeItem, PreferencesTreeItem } from "../tree";
import editJsonFile = require("edit-json-file");

Expand Down Expand Up @@ -33,7 +33,7 @@ async function askName(arg: Argument, existingArgs: string[]): Promise<string |
}

async function askType(arg: Argument): Promise<string | undefined> {
const result = await vscode.window.showQuickPick(["text", "password"], {
const result = await vscode.window.showQuickPick(["text", "password", "dropdown"], {
placeHolder: "Choose Type",
title: "Type",
});
Expand Down Expand Up @@ -148,6 +148,12 @@ export async function addCommandArgumentCmd(manager: ExtensionManager, args: any
if ((await askRequired(argument)) === undefined) {
return;
}
if (argument.type === ArgumentType.dropdown) {
argument.data = [
{ title: "Title 1", value: "Value 1" },
{ title: "Title 2", value: "Value 2" },
];
}
const j = editJsonFile(pkgJSON);
j.append(`commands.${index}.arguments`, argument);
j.save();
Expand Down
7 changes: 7 additions & 0 deletions src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ export interface Argument {
type?: string;
placeholder?: string;
required?: boolean;
data?: PreferenceData[];
}

export enum ArgumentType {
textfield = "textfield",
password = "password",
dropdown = "dropdown",
}

export interface Manifest {
Expand Down

0 comments on commit a43907a

Please sign in to comment.