|
| 1 | +Index: code-server/lib/vscode/src/vs/workbench/api/browser/mainThreadCLICommands.ts |
| 2 | +=================================================================== |
| 3 | +--- code-server.orig/lib/vscode/src/vs/workbench/api/browser/mainThreadCLICommands.ts |
| 4 | ++++ code-server/lib/vscode/src/vs/workbench/api/browser/mainThreadCLICommands.ts |
| 5 | +@@ -8,6 +8,7 @@ import { isWeb } from 'vs/base/common/pl |
| 6 | + import { isString } from 'vs/base/common/types'; |
| 7 | + import { URI, UriComponents } from 'vs/base/common/uri'; |
| 8 | + import { localize } from 'vs/nls'; |
| 9 | ++import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; |
| 10 | + import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/commands'; |
| 11 | + import { IExtensionGalleryService, IExtensionManagementService } from 'vs/platform/extensionManagement/common/extensionManagement'; |
| 12 | + import { ExtensionManagementCLI } from 'vs/platform/extensionManagement/common/extensionManagementCLI'; |
| 13 | +@@ -89,6 +90,11 @@ CommandsRegistry.registerCommand('_remot |
| 14 | + return lines.join('\n'); |
| 15 | + }); |
| 16 | + |
| 17 | ++CommandsRegistry.registerCommand('_remoteCLI.setClipboard', function (accessor: ServicesAccessor, content: string) { |
| 18 | ++ const clipboardService = accessor.get(IClipboardService); |
| 19 | ++ clipboardService.writeText(content); |
| 20 | ++}) |
| 21 | ++ |
| 22 | + class RemoteExtensionManagementCLI extends ExtensionManagementCLI { |
| 23 | + |
| 24 | + private _location: string | undefined; |
| 25 | +Index: code-server/lib/vscode/src/vs/workbench/api/node/extHostCLIServer.ts |
| 26 | +=================================================================== |
| 27 | +--- code-server.orig/lib/vscode/src/vs/workbench/api/node/extHostCLIServer.ts |
| 28 | ++++ code-server/lib/vscode/src/vs/workbench/api/node/extHostCLIServer.ts |
| 29 | +@@ -43,7 +43,12 @@ export interface ExtensionManagementPipe |
| 30 | + force?: boolean; |
| 31 | + } |
| 32 | + |
| 33 | +-export type PipeCommand = OpenCommandPipeArgs | StatusPipeArgs | OpenExternalCommandPipeArgs | ExtensionManagementPipeArgs; |
| 34 | ++export interface ClipboardPipeArgs { |
| 35 | ++ type: 'clipboard'; |
| 36 | ++ content: string; |
| 37 | ++} |
| 38 | ++ |
| 39 | ++export type PipeCommand = OpenCommandPipeArgs | StatusPipeArgs | OpenExternalCommandPipeArgs | ExtensionManagementPipeArgs | ClipboardPipeArgs; |
| 40 | + |
| 41 | + export interface ICommandsExecuter { |
| 42 | + executeCommand<T>(id: string, ...args: any[]): Promise<T>; |
| 43 | +@@ -105,6 +110,9 @@ export class CLIServerBase { |
| 44 | + case 'extensionManagement': |
| 45 | + returnObj = await this.manageExtensions(data); |
| 46 | + break; |
| 47 | ++ case 'clipboard': |
| 48 | ++ returnObj = await this.clipboard(data); |
| 49 | ++ break; |
| 50 | + default: |
| 51 | + sendResponse(404, `Unknown message type: ${data.type}`); |
| 52 | + break; |
| 53 | +@@ -172,6 +180,10 @@ export class CLIServerBase { |
| 54 | + return await this._commands.executeCommand<string | undefined>('_remoteCLI.getSystemStatus'); |
| 55 | + } |
| 56 | + |
| 57 | ++ private async clipboard(data: ClipboardPipeArgs): Promise<undefined> { |
| 58 | ++ return await this._commands.executeCommand('_remoteCLI.setClipboard', data.content); |
| 59 | ++ } |
| 60 | ++ |
| 61 | + dispose(): void { |
| 62 | + this._server.close(); |
| 63 | + |
| 64 | +Index: code-server/lib/vscode/src/vs/workbench/contrib/terminal/browser/remoteTerminalBackend.ts |
| 65 | +=================================================================== |
| 66 | +--- code-server.orig/lib/vscode/src/vs/workbench/contrib/terminal/browser/remoteTerminalBackend.ts |
| 67 | ++++ code-server/lib/vscode/src/vs/workbench/contrib/terminal/browser/remoteTerminalBackend.ts |
| 68 | +@@ -97,7 +97,7 @@ class RemoteTerminalBackend extends Base |
| 69 | + } |
| 70 | + }); |
| 71 | + |
| 72 | +- const allowedCommands = ['_remoteCLI.openExternal', '_remoteCLI.windowOpen', '_remoteCLI.getSystemStatus', '_remoteCLI.manageExtensions']; |
| 73 | ++ const allowedCommands = ['_remoteCLI.openExternal', '_remoteCLI.windowOpen', '_remoteCLI.getSystemStatus', '_remoteCLI.manageExtensions', '_remoteCLI.setClipboard']; |
| 74 | + this._remoteTerminalChannel.onExecuteCommand(async e => { |
| 75 | + // Ensure this request for for this window |
| 76 | + const pty = this._ptys.get(e.persistentProcessId); |
| 77 | +Index: code-server/lib/vscode/src/vs/platform/environment/common/argv.ts |
| 78 | +=================================================================== |
| 79 | +--- code-server.orig/lib/vscode/src/vs/platform/environment/common/argv.ts |
| 80 | ++++ code-server/lib/vscode/src/vs/platform/environment/common/argv.ts |
| 81 | +@@ -119,6 +119,7 @@ export interface NativeParsedArgs { |
| 82 | + sandbox?: boolean; |
| 83 | + |
| 84 | + 'enable-coi'?: boolean; |
| 85 | ++ 'stdin-to-clipboard'?: boolean; |
| 86 | + |
| 87 | + // chromium command line args: https://electronjs.org/docs/all#supported-chrome-command-line-switches |
| 88 | + 'no-proxy-server'?: boolean; |
| 89 | +Index: code-server/lib/vscode/src/vs/platform/environment/node/argv.ts |
| 90 | +=================================================================== |
| 91 | +--- code-server.orig/lib/vscode/src/vs/platform/environment/node/argv.ts |
| 92 | ++++ code-server/lib/vscode/src/vs/platform/environment/node/argv.ts |
| 93 | +@@ -90,6 +90,7 @@ export const OPTIONS: OptionDescriptions |
| 94 | + 'user-data-dir': { type: 'string', cat: 'o', args: 'dir', description: localize('userDataDir', "Specifies the directory that user data is kept in. Can be used to open multiple distinct instances of Code.") }, |
| 95 | + 'profile': { type: 'string', 'cat': 'o', args: 'profileName', description: localize('profileName', "Opens the provided folder or workspace with the given profile and associates the profile with the workspace. If the profile does not exist, a new empty one is created.") }, |
| 96 | + 'help': { type: 'boolean', cat: 'o', alias: 'h', description: localize('help', "Print usage.") }, |
| 97 | ++ 'stdin-to-clipboard': { type: 'boolean', cat: 'o', alias: 'c', description: localize('clipboard', "copies the STDIN to the clipboard") }, |
| 98 | + |
| 99 | + 'extensions-dir': { type: 'string', deprecates: ['extensionHomePath'], cat: 'e', args: 'dir', description: localize('extensionHomePath', "Set the root path for extensions.") }, |
| 100 | + 'extensions-download-dir': { type: 'string' }, |
| 101 | +Index: code-server/lib/vscode/src/vs/server/node/server.cli.ts |
| 102 | +=================================================================== |
| 103 | +--- code-server.orig/lib/vscode/src/vs/server/node/server.cli.ts |
| 104 | ++++ code-server/lib/vscode/src/vs/server/node/server.cli.ts |
| 105 | +@@ -76,6 +76,7 @@ const isSupportedForPipe = (optionId: ke |
| 106 | + case 'verbose': |
| 107 | + case 'remote': |
| 108 | + case 'locate-shell-integration-path': |
| 109 | ++ case 'stdin-to-clipboard': |
| 110 | + return true; |
| 111 | + default: |
| 112 | + return false; |
| 113 | +@@ -293,6 +294,23 @@ export async function main(desc: Product |
| 114 | + } |
| 115 | + } |
| 116 | + } else { |
| 117 | ++ if (parsedArgs['stdin-to-clipboard']) { |
| 118 | ++ if(!hasStdinWithoutTty()) { |
| 119 | ++ console.error("stdin has a tty."); |
| 120 | ++ return; |
| 121 | ++ } |
| 122 | ++ const fs = require("fs"); |
| 123 | ++ const stdinBuffer = fs.readFileSync(0); // STDIN_FILENO = 0 |
| 124 | ++ const clipboardContent = stdinBuffer.toString(); |
| 125 | ++ sendToPipe({ |
| 126 | ++ type: 'clipboard', |
| 127 | ++ content: clipboardContent |
| 128 | ++ }, verbose).catch(e => { |
| 129 | ++ console.error('Error when requesting status:', e); |
| 130 | ++ }); |
| 131 | ++ return; |
| 132 | ++ } |
| 133 | ++ |
| 134 | + if (parsedArgs.status) { |
| 135 | + sendToPipe({ |
| 136 | + type: 'status' |
0 commit comments