Add "--stdin-file-ext" option
This option allows to define the extension of the file generated by reading the stdin when the "-" parameter is passed.
This commit is contained in:
parent
6effc2377b
commit
842f7d02ba
|
@ -160,7 +160,7 @@ export async function main(argv: string[]): Promise<any> {
|
|||
// checking for stdin being connected to a TTY is not enough (https://github.com/microsoft/vscode/issues/40351)
|
||||
|
||||
if (hasReadStdinArg) {
|
||||
stdinFilePath = getStdinFilePath();
|
||||
stdinFilePath = getStdinFilePath(args['stdin-file-ext']);
|
||||
|
||||
// returns a file path where stdin input is written into (write in progress).
|
||||
try {
|
||||
|
|
|
@ -23,6 +23,7 @@ export interface NativeParsedArgs {
|
|||
'new-window'?: boolean;
|
||||
'unity-launch'?: boolean; // Always open a new window, except if opening the first window or opening a file or folder as part of the launch.
|
||||
'reuse-window'?: boolean;
|
||||
'stdin-file-ext'?: string;
|
||||
locale?: string;
|
||||
'user-data-dir'?: string;
|
||||
'prof-startup'?: boolean;
|
||||
|
|
|
@ -45,6 +45,7 @@ export const OPTIONS: OptionDescriptions<Required<NativeParsedArgs>> = {
|
|||
'reuse-window': { type: 'boolean', cat: 'o', alias: 'r', description: localize('reuseWindow', "Force to open a file or folder in an already opened window.") },
|
||||
'wait': { type: 'boolean', cat: 'o', alias: 'w', description: localize('wait', "Wait for the files to be closed before returning.") },
|
||||
'waitMarkerFilePath': { type: 'string' },
|
||||
'stdin-file-ext': { type: 'string', cat: 'o', description: localize('stdinFileExt', "The extension appended to the file generated by stdin reading.") },
|
||||
'locale': { type: 'string', cat: 'o', args: 'locale', description: localize('locale', "The locale to use (e.g. en-US or zh-TW).") },
|
||||
'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.") },
|
||||
'help': { type: 'boolean', cat: 'o', alias: 'h', description: localize('help', "Print usage.") },
|
||||
|
|
|
@ -35,8 +35,10 @@ export function stdinDataListener(durationinMs: number): Promise<boolean> {
|
|||
});
|
||||
}
|
||||
|
||||
export function getStdinFilePath(): string {
|
||||
return paths.join(os.tmpdir(), `code-stdin-${Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 3)}`);
|
||||
export function getStdinFilePath(ext?: string | undefined): string {
|
||||
const suffix = ext ? `.${ext}` : '';
|
||||
const rnd = Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 3);
|
||||
return paths.join(os.tmpdir(), `code-stdin-${rnd}${suffix}`);
|
||||
}
|
||||
|
||||
export async function readFromStdin(targetPath: string, verbose: boolean): Promise<void> {
|
||||
|
|
Loading…
Reference in a new issue