johnpapa / vscode-peacock

Subtly change the color of your Visual Studio Code workspace. Ideal when you have multiple VS Code instances, use VS Live Share, or use VS Code's Remote features, and you want to quickly identify your editor.
MIT License
1.04k stars 117 forks source link

Add arguments to the enterColor command handler #118

Closed ksivamuthu closed 5 years ago

ksivamuthu commented 5 years ago

Add arguments to the command handler

Why?

I'm developing a vscode extension - VSCode Peacock Twitch Extension that connects twitch chat client. If twitch viewers chat with the command "!peacock #c0c0c0", the code is calling peacock extension programmatically.

 await vscode.commands.executeCommand('peacock.enterColor', "#c0c0c0");

The current vscode-peacock enterColorHandler implementation is not checking the parameter and prompt user for input. It would be great if command handler code will check the passed parameter first and if there is no parameter, then prompt the user input to get color.

Proposed changes in commands.ts

export async function enterColorHandler(color: string) {
  const input = color ? color : await promptForColor();
   ...
}

Version Information

macOS Mojave VS Code version Stable Peacock v2.0.0

Repro steps

  1. Create new vscode extension with vscode-peacock as a dependency
  2. Add a test command and call the below code in handler
    await vscode.commands.executeCommand('peacock.enterColor', "#c0c0c0");
ksivamuthu commented 5 years ago

Done. PR is merged and closing the issue.