Skip to content

Commit eaa7d58

Browse files
committed
fix: example api
1 parent aed7a92 commit eaa7d58

File tree

1 file changed

+53
-54
lines changed

1 file changed

+53
-54
lines changed

examples/sample1/src/api.ts

Lines changed: 53 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,6 @@ export interface PythonCommandRunConfiguration {
4848
args?: string[];
4949
}
5050

51-
export enum TerminalShellType {
52-
powershell = 'powershell',
53-
powershellCore = 'powershellCore',
54-
commandPrompt = 'commandPrompt',
55-
gitbash = 'gitbash',
56-
bash = 'bash',
57-
zsh = 'zsh',
58-
ksh = 'ksh',
59-
fish = 'fish',
60-
cshell = 'cshell',
61-
tcshell = 'tcshell',
62-
nushell = 'nushell',
63-
wsl = 'wsl',
64-
xonsh = 'xonsh',
65-
unknown = 'unknown',
66-
}
67-
6851
/**
6952
* Contains details on how to use a particular python environment
7053
*
@@ -73,7 +56,7 @@ export enum TerminalShellType {
7356
* 2. If {@link PythonEnvironmentExecutionInfo.activatedRun} is not provided, then:
7457
* - If {@link PythonEnvironmentExecutionInfo.shellActivation} is provided and shell type is known, then that will be used.
7558
* - If {@link PythonEnvironmentExecutionInfo.shellActivation} is provided and shell type is not known, then:
76-
* - {@link TerminalShellType.unknown} will be used if provided.
59+
* - 'unknown' will be used if provided.
7760
* - {@link PythonEnvironmentExecutionInfo.activation} will be used otherwise.
7861
* - If {@link PythonEnvironmentExecutionInfo.shellActivation} is not provided, then {@link PythonEnvironmentExecutionInfo.activation} will be used.
7962
* - If {@link PythonEnvironmentExecutionInfo.activation} is not provided, then {@link PythonEnvironmentExecutionInfo.run} will be used.
@@ -82,7 +65,7 @@ export enum TerminalShellType {
8265
* 1. If {@link PythonEnvironmentExecutionInfo.shellActivation} is provided and shell type is known, then that will be used.
8366
* 2. If {@link PythonEnvironmentExecutionInfo.shellActivation} is provided and shell type is not known, then {@link PythonEnvironmentExecutionInfo.activation} will be used.
8467
* 3. If {@link PythonEnvironmentExecutionInfo.shellActivation} is not provided, then:
85-
* - {@link TerminalShellType.unknown} will be used if provided.
68+
* - 'unknown' will be used if provided.
8669
* - {@link PythonEnvironmentExecutionInfo.activation} will be used otherwise.
8770
* 4. If {@link PythonEnvironmentExecutionInfo.activation} is not provided, then {@link PythonEnvironmentExecutionInfo.run} will be used.
8871
*
@@ -107,11 +90,11 @@ export interface PythonEnvironmentExecutionInfo {
10790
/**
10891
* Details on how to activate an environment using a shell specific command.
10992
* If set this will override the {@link PythonEnvironmentExecutionInfo.activation}.
110-
* {@link TerminalShellType.unknown} is used if shell type is not known.
111-
* If {@link TerminalShellType.unknown} is not provided and shell type is not known then
93+
* 'unknown' is used if shell type is not known.
94+
* If 'unknown' is not provided and shell type is not known then
11295
* {@link PythonEnvironmentExecutionInfo.activation} if set.
11396
*/
114-
shellActivation?: Map<TerminalShellType, PythonCommandRunConfiguration[]>;
97+
shellActivation?: Map<string, PythonCommandRunConfiguration[]>;
11598

11699
/**
117100
* Details on how to deactivate an environment.
@@ -121,11 +104,11 @@ export interface PythonEnvironmentExecutionInfo {
121104
/**
122105
* Details on how to deactivate an environment using a shell specific command.
123106
* If set this will override the {@link PythonEnvironmentExecutionInfo.deactivation} property.
124-
* {@link TerminalShellType.unknown} is used if shell type is not known.
125-
* If {@link TerminalShellType.unknown} is not provided and shell type is not known then
107+
* 'unknown' is used if shell type is not known.
108+
* If 'unknown' is not provided and shell type is not known then
126109
* {@link PythonEnvironmentExecutionInfo.deactivation} if set.
127110
*/
128-
shellDeactivation?: Map<TerminalShellType, PythonCommandRunConfiguration[]>;
111+
shellDeactivation?: Map<string, PythonCommandRunConfiguration[]>;
129112
}
130113

131114
/**
@@ -592,20 +575,12 @@ export interface PackageManager {
592575
log?: LogOutputChannel;
593576

594577
/**
595-
* Installs packages in the specified Python environment.
578+
* Installs/Uninstall packages in the specified Python environment.
596579
* @param environment - The Python environment in which to install packages.
597580
* @param packages - The packages to install.
598581
* @returns A promise that resolves when the installation is complete.
599582
*/
600-
install(environment: PythonEnvironment, packages?: string[], options?: PackageInstallOptions): Promise<void>;
601-
602-
/**
603-
* Uninstalls packages from the specified Python environment.
604-
* @param environment - The Python environment from which to uninstall packages.
605-
* @param packages - The packages to uninstall, which can be an array of packages or strings.
606-
* @returns A promise that resolves when the uninstall is complete.
607-
*/
608-
uninstall(environment: PythonEnvironment, packages?: Package[] | string[]): Promise<void>;
583+
manage(environment: PythonEnvironment, options: PackageManagementOptions): Promise<void>;
609584

610585
/**
611586
* Refreshes the package list for the specified Python environment.
@@ -730,15 +705,47 @@ export interface DidChangePythonProjectsEventArgs {
730705
removed: PythonProject[];
731706
}
732707

733-
/**
734-
* Options for package installation.
735-
*/
736-
export interface PackageInstallOptions {
737-
/**
738-
* Upgrade the packages if it is already installed.
739-
*/
740-
upgrade?: boolean;
741-
}
708+
export type PackageManagementOptions =
709+
| {
710+
/**
711+
* Upgrade the packages if it is already installed.
712+
*/
713+
upgrade?: boolean;
714+
715+
/**
716+
* Show option to skip package installation
717+
*/
718+
showSkipOption?: boolean;
719+
/**
720+
* The list of packages to install.
721+
*/
722+
install: string[];
723+
724+
/**
725+
* The list of packages to uninstall.
726+
*/
727+
uninstall?: string[];
728+
}
729+
| {
730+
/**
731+
* Upgrade the packages if it is already installed.
732+
*/
733+
upgrade?: boolean;
734+
735+
/**
736+
* Show option to skip package installation
737+
*/
738+
showSkipOption?: boolean;
739+
/**
740+
* The list of packages to install.
741+
*/
742+
install?: string[];
743+
744+
/**
745+
* The list of packages to uninstall.
746+
*/
747+
uninstall: string[];
748+
};
742749

743750
export interface PythonProcess {
744751
/**
@@ -921,21 +928,13 @@ export interface PythonPackageItemApi {
921928

922929
export interface PythonPackageManagementApi {
923930
/**
924-
* Install packages into a Python Environment.
931+
* Install/Uninstall packages into a Python Environment.
925932
*
926933
* @param environment The Python Environment into which packages are to be installed.
927934
* @param packages The packages to install.
928935
* @param options Options for installing packages.
929936
*/
930-
installPackages(environment: PythonEnvironment, packages: string[], options?: PackageInstallOptions): Promise<void>;
931-
932-
/**
933-
* Uninstall packages from a Python Environment.
934-
*
935-
* @param environment The Python Environment from which packages are to be uninstalled.
936-
* @param packages The packages to uninstall.
937-
*/
938-
uninstallPackages(environment: PythonEnvironment, packages: PackageInfo[] | string[]): Promise<void>;
937+
managePackages(environment: PythonEnvironment, options: PackageManagementOptions): Promise<void>;
939938
}
940939

941940
export interface PythonPackageManagerApi

0 commit comments

Comments
 (0)