From a43907ad62739ff1999f4481df3505c823522b17 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Per=20Nielsen=20Tik=C3=A6r?= <per@raycast.com>
Date: Fri, 23 Feb 2024 16:09:41 +0100
Subject: [PATCH] Added support for dropdown in arguments (#32)

Added support for dropdown in arguments
---
 CHANGELOG.md                       |  4 ++++
 package.json                       |  5 ++++-
 src/commands/addCommandArgument.ts | 10 ++++++++--
 src/manifest.ts                    |  7 +++++++
 4 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 89adbaa..96297cd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Change Log
 
+## 0.17
+
+- Add dropdown type for arguments
+
 ## 0.16
 
 - Add `Add Swift Support` command
diff --git a/package.json b/package.json
index b531c45..f83755f 100644
--- a/package.json
+++ b/package.json
@@ -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"
diff --git a/src/commands/addCommandArgument.ts b/src/commands/addCommandArgument.ts
index 566b80f..c41d8c2 100644
--- a/src/commands/addCommandArgument.ts
+++ b/src/commands/addCommandArgument.ts
@@ -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");
 
@@ -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",
   });
@@ -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();
diff --git a/src/manifest.ts b/src/manifest.ts
index 9f09d33..81a6eab 100644
--- a/src/manifest.ts
+++ b/src/manifest.ts
@@ -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 {