11import { Architecture , ExecResult } from "@/types" ;
22import { ExecOptions , ShellString , exec } from "shelljs" ;
3+ import { ImageResult , RemoveImageCommandFlags } from "@/types/images" ;
34import {
45 LogsCommandFlags ,
5- RmCommandFlags ,
6+ RemoveCommandFlags ,
67 RunCommandFlags ,
78 StopCommandFlags ,
89} from "@/types/container" ;
910
1011import { ChildProcess } from "child_process" ;
1112import { GlobalFlags } from "@/types/global" ;
12- import { ImageResult } from "@/types/images" ;
1313import { LoginCommandFlags } from "@/types/registry" ;
1414import { paramCase } from "change-case" ;
1515import { platform } from "@/utils" ;
@@ -90,6 +90,12 @@ export default abstract class BaseBackend {
9090
9191 return ( await this . exec ( command , { async : false } ) ) as ShellString ;
9292 }
93+
94+ async logout ( server ?: string ) : Promise < ShellString > {
95+ const command = `${ this . container } logout ${ server } ` ;
96+
97+ return ( await this . exec ( command , { async : false } ) ) as ShellString ;
98+ }
9399 //#endregion
94100
95101 //#region containers
@@ -113,7 +119,7 @@ export default abstract class BaseBackend {
113119
114120 async remove (
115121 container : string | string [ ] ,
116- flags ?: RmCommandFlags
122+ flags ?: RemoveCommandFlags
117123 ) : Promise < ShellString > {
118124 const containers = Array . isArray ( container )
119125 ? container . join ( " " )
@@ -159,5 +165,17 @@ export default abstract class BaseBackend {
159165 } ) ;
160166 } ) ;
161167 }
168+
169+ async removeImage (
170+ image : string | string [ ] ,
171+ flags ?: RemoveImageCommandFlags
172+ ) : Promise < ShellString > {
173+ const images = Array . isArray ( image ) ? image . join ( " " ) : image ;
174+
175+ return ( await this . exec (
176+ `${ this . container } rmi ${ this . mergeFlags ( flags ) } ${ images } ` ,
177+ { async : false }
178+ ) ) as ShellString ;
179+ }
162180 //#endregion
163181}
0 commit comments