[vscode-spring-cli] command add support
This commit is contained in:
@@ -20,6 +20,10 @@ export interface BootAddMetadata {
|
||||
catalog?: string;
|
||||
}
|
||||
|
||||
export interface commandAddMetadata {
|
||||
url: string;
|
||||
}
|
||||
|
||||
export interface ProjectCatalog {
|
||||
name: string;
|
||||
url: string;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BootAddMetadata, BootNewMetadata, Project, ProjectCatalog } from "./cli-types";
|
||||
import { BootAddMetadata, BootNewMetadata, Project, ProjectCatalog, commandAddMetadata } from "./cli-types";
|
||||
import { ProcessExecution, ProgressLocation, Task, TaskScope, Uri, env, tasks, window, workspace } from "vscode";
|
||||
import cp from "child_process";
|
||||
import { homedir } from "os";
|
||||
@@ -28,6 +28,16 @@ export class Cli {
|
||||
return this.fetchJson("Fetching Available Catalogs...", undefined, ["project-catalog", "list-available"]);
|
||||
}
|
||||
|
||||
commandAdd(metadata: commandAddMetadata) {
|
||||
const args = [
|
||||
"command",
|
||||
"add",
|
||||
"--from",
|
||||
metadata.url
|
||||
];
|
||||
this.exec("Add Command", metadata.url, args);
|
||||
}
|
||||
|
||||
projectCatalogAdd(catalog: ProjectCatalog): Promise<void> {
|
||||
const args = [
|
||||
"project-catalog",
|
||||
@@ -135,7 +145,7 @@ export class Cli {
|
||||
return new Promise<void>(async (resolve, reject) => {
|
||||
const processOpts = { cwd: cwd || getWorkspaceRoot()?.fsPath || homedir() };
|
||||
const process = this.executable.endsWith(".jar") ? new ProcessExecution("java", [ "-jar", this.executable, ...args], processOpts) : new ProcessExecution(this.executable, args, processOpts);
|
||||
const task = new Task({ type: SPRING_CLI_TASK_TYPE}, cwd ? workspace.getWorkspaceFolder(Uri.file(cwd)) : TaskScope.Global, `${title}: ${message}`, SPRING_CLI_TASK_TYPE, process);
|
||||
const task = new Task({ type: SPRING_CLI_TASK_TYPE }, cwd ? workspace.getWorkspaceFolder(Uri.file(cwd)) : TaskScope.Global, `${title}: ${message}`, SPRING_CLI_TASK_TYPE, process);
|
||||
const taskExecution = await tasks.executeTask(task);
|
||||
if (cancellation.isCancellationRequested) {
|
||||
reject();
|
||||
|
||||
35
vscode-extensions/vscode-spring-cli/src/command.ts
Normal file
35
vscode-extensions/vscode-spring-cli/src/command.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { Uri, window } from "vscode";
|
||||
import { enterText } from "./utils";
|
||||
import { CLI } from "./extension";
|
||||
|
||||
export async function handleCommandAdd() {
|
||||
let url;
|
||||
try {
|
||||
url = await enterText({
|
||||
title: "URL",
|
||||
prompt: "Enter Repository URL",
|
||||
placeholder: "https://github.com/my-org/my-command",
|
||||
validate: async v => {
|
||||
try {
|
||||
Uri.parse(v, true);
|
||||
} catch (error) {
|
||||
return "Invalid URL value";
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
// Cancelled - ignore the error
|
||||
}
|
||||
|
||||
if (url) {
|
||||
CLI.commandAdd({url});
|
||||
}
|
||||
}
|
||||
|
||||
export async function handleCommandRemove() {
|
||||
window.showErrorMessage("Not Implemented!");
|
||||
}
|
||||
|
||||
export async function handleCommandNew() {
|
||||
window.showErrorMessage("Not Implemented!");
|
||||
}
|
||||
Reference in New Issue
Block a user