Skip to content

Commit a2bd5a1

Browse files
committed
feat: added stop command
1 parent 2f4d192 commit a2bd5a1

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nerdctl",
3-
"version": "0.0.3",
3+
"version": "0.0.6",
44
"main": "dist/index.js",
55
"types": "dist/index.d.ts",
66
"description": "Node wrapper for nerdctl",

src/types/container.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ export interface LogsCommandFlags extends GlobalFlags {
6565
until?: string;
6666
}
6767

68+
export interface StopCommandFlags extends GlobalFlags {
69+
time?: string;
70+
}
71+
6872
export interface RmCommandFlags extends GlobalFlags {
6973
force?: boolean;
7074
volumes?: boolean;

src/vms/base.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,14 @@ export default abstract class BaseBackend {
7676
flags?: RunCommandFlags
7777
): Promise<ExecResult | string>;
7878

79-
abstract rm(container: string, flags?: RmCommandFlags): Promise<ShellString>;
79+
abstract stop(
80+
container: string | string[],
81+
flags?: RmCommandFlags
82+
): Promise<ShellString>;
83+
abstract rm(
84+
container: string | string[],
85+
flags?: RmCommandFlags
86+
): Promise<ShellString>;
8087

8188
abstract pullImage(image: string): Promise<ChildProcess>;
8289
abstract getImages(): Promise<ImageResult[]>;

src/vms/lima.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
LogsCommandFlags,
33
RmCommandFlags,
44
RunCommandFlags,
5+
StopCommandFlags,
56
} from "@/types/container";
67

78
import BaseBackend from "./base";
@@ -47,9 +48,28 @@ export default class LimaBackend extends BaseBackend {
4748
});
4849
}
4950

50-
async rm(container: string, flags?: RmCommandFlags): Promise<ShellString> {
51+
async stop(
52+
container: string | string[],
53+
flags?: StopCommandFlags
54+
): Promise<ShellString> {
55+
const containers = Array.isArray(container)
56+
? container.join(" ")
57+
: container;
5158
return (await this.exec(
52-
`${this.container} rm ${this.mergeFlags(flags)} ${container}`,
59+
`${this.container} stop ${this.mergeFlags(flags)} ${containers}`,
60+
{ async: false }
61+
)) as ShellString;
62+
}
63+
64+
async rm(
65+
container: string | string[],
66+
flags?: RmCommandFlags
67+
): Promise<ShellString> {
68+
const containers = Array.isArray(container)
69+
? container.join(" ")
70+
: container;
71+
return (await this.exec(
72+
`${this.container} rm ${this.mergeFlags(flags)} ${containers}`,
5373
{ async: false }
5474
)) as ShellString;
5575
}

0 commit comments

Comments
 (0)