Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Project/Template Info button to Extension #212

Merged
merged 4 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@
"command": "pros.new",
"title": "PROS: Create New PROS Project"
},
{
"command": "pros.infoProject",
"title": "PROS: Project Information"
},
{
"command": "pros.welcome",
"title": "PROS: Welcome"
Expand Down
1 change: 1 addition & 0 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ export * from "./base-command";
export * from "./set-team-number";
export * from "./set-robot-name";
export * from "./runvision";
export * from "./info-project";
41 changes: 41 additions & 0 deletions src/commands/info-project.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import * as vscode from "vscode";
import { BaseCommand, BaseCommandOptions } from "./base-command";
import { StringDecoder } from "string_decoder";
import { PREFIX } from "./cli-parsing";

export const infoProject = async () => {
const infoProjectCommandOptions: BaseCommandOptions = {
command: "pros",
args: ["c", "info-project", "--machine-output"],
message: undefined,
requiresProsProject: true,
extraOutput: true,
successMessage: "hidden",
};

const infoProjectCommand: BaseCommand = new BaseCommand(
infoProjectCommandOptions
);

try {
await infoProjectCommand.runCommand();
} catch (err: any) {
await vscode.window.showErrorMessage(err.message);
}

var output = "Installed Templates: ";
for (let e of infoProjectCommand.extraOutput!) {
if (e.startsWith(PREFIX)) {
let jdata = JSON.parse(e.substr(PREFIX.length));
if (jdata.type === "finalize") {
const target = jdata.data.project.target;
for (let t of jdata.data.project.templates) {
output += `${t.name}: ${t.version}, `;
}
}
}
}
// Remove trailing comma
output = output.slice(0, -2);
vscode.window.showInformationMessage(output);
};
2 changes: 2 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
stop,
createNewProject,
upgradeProject,
infoProject,
upload,
capture,
medic,
Expand Down Expand Up @@ -227,6 +228,7 @@ export async function activate(context: vscode.ExtensionContext) {

setupCommandBlocker("pros.upgrade", upgradeProject);
setupCommandBlocker("pros.new", createNewProject);
setupCommandBlocker("pros.infoProject", infoProject);

// Beta commands (notice the fourth argument is set to true for these)
setupCommandBlocker("pros.installVision", installVision, context, true);
Expand Down
1 change: 1 addition & 0 deletions src/views/tree-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class TreeDataProvider implements vscode.TreeDataProvider<TreeItem> {
new TreeItem("Conductor", [
new TreeItem("Upgrade Project", undefined, "pros.upgrade"),
new TreeItem("Create Project", undefined, "pros.new"),
new TreeItem("Project/Template Info", undefined, "pros.infoProject"),
// open branchline will go here in the future
]),
new TreeItem("Manage Installations", [
Expand Down
Loading