This repository has been archived by the owner on Dec 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow developers on Windows specify what kind of integrated terminal …
…they use (#315)
- Loading branch information
1 parent
62aca26
commit ef0dc49
Showing
22 changed files
with
444 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { WorkspaceConfiguration, workspace } from 'vscode'; | ||
|
||
/** | ||
* The main goal of the class is to store the parameter's name and to expose functions to get/set | ||
* the value of the parameter | ||
*/ | ||
export class ConfigurationParameter { | ||
private _parameterName: string; | ||
|
||
public constructor(parameterName: string) { | ||
this._parameterName = parameterName; | ||
} | ||
|
||
public getValue(): any { | ||
return this.getConfiguration().get(this._parameterName); | ||
} | ||
|
||
public async setValue(value: any): Promise<void> { | ||
await this.getConfiguration().update(this._parameterName, value, true); | ||
} | ||
|
||
private getConfiguration(): WorkspaceConfiguration { | ||
return workspace.getConfiguration(''); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Shell } from './Shell'; | ||
|
||
/** | ||
* The interface declares methods which should be implemented for any shell providers | ||
*/ | ||
export interface IShellProvider { | ||
getValue(): Promise<Shell | undefined>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { IShellProvider } from './IShellProvider'; | ||
import { Shell } from './Shell'; | ||
|
||
/** | ||
* The main goal of the class is to provide the current value of the shell | ||
*/ | ||
export class NotWindowsShellProvider implements IShellProvider { | ||
public getValue(): Promise<Shell | undefined> { | ||
// All OS expect Windows use Shell | ||
return Promise.resolve(Shell.Shell); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* A enumeration of possible shells | ||
*/ | ||
export enum Shell { | ||
PowerShell, | ||
Cmd, | ||
Shell, | ||
Wsl | ||
} | ||
|
||
/** | ||
* The list of all shell values | ||
*/ | ||
export const VALUES = [Shell.PowerShell, Shell.Cmd, Shell.Shell, Shell.Wsl]; | ||
|
||
/** | ||
* The list of textual forms of all shell values | ||
*/ | ||
export const VALUE_STRINGS = VALUES.map(toString); | ||
|
||
export function fromString(s: string): Shell | undefined { | ||
switch (s) { | ||
case 'powershell': | ||
return Shell.PowerShell; | ||
case 'cmd': | ||
return Shell.Cmd; | ||
case 'shell': | ||
return Shell.Shell; | ||
case 'wsl': | ||
return Shell.Wsl; | ||
default: | ||
return undefined; | ||
} | ||
} | ||
|
||
/** | ||
* Returns the textual form of the specified shell | ||
* @param shell The shell to convert to string | ||
*/ | ||
export function toString(shell: Shell): string { | ||
switch (shell) { | ||
case Shell.PowerShell: | ||
return 'powershell'; | ||
case Shell.Cmd: | ||
return 'cmd'; | ||
case Shell.Shell: | ||
return 'shell'; | ||
case Shell.Wsl: | ||
return 'wsl'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { ILogger } from './components/logging/ILogger'; | ||
import { IShellProvider } from './IShellProvider'; | ||
import { Shell } from './Shell'; | ||
import { NotWindowsShellProvider } from './NotWindowsShellProvider'; | ||
import { WindowsShellProvider } from './WindowsShellProvider'; | ||
|
||
/** | ||
* The main goal of the class is to provide the current value of the shell | ||
*/ | ||
export class ShellProviderManager { | ||
private _shellProvider: IShellProvider; | ||
|
||
/** | ||
* Creates a new object which can be used to get the current value of the shell | ||
* @param logger The logger which is used to create child logger which will be used to log | ||
* messages | ||
*/ | ||
public constructor(logger: ILogger) { | ||
if (process.platform === 'win32') { | ||
this._shellProvider = new WindowsShellProvider(logger); | ||
} else { | ||
this._shellProvider = new NotWindowsShellProvider(); | ||
} | ||
} | ||
|
||
/** | ||
* Gets the current value of the shell and returns it | ||
*/ | ||
public async getValue(): Promise<Shell | undefined> { | ||
return await this._shellProvider.getValue(); | ||
} | ||
} |
Oops, something went wrong.