Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rm for single container #111

Closed
MOTORIST opened this issue Apr 22, 2020 · 6 comments · Fixed by #112
Closed

rm for single container #111

MOTORIST opened this issue Apr 22, 2020 · 6 comments · Fixed by #112

Comments

@MOTORIST
Copy link

Hi!
Usage rm:
rm [options] [SERVICE...]

Why not?

export const rm = function (options?: IDockerComposeOptions, container?: string): Promise<IDockerComposeResult>;
@AlexZeitler
Copy link
Contributor

AlexZeitler commented Apr 22, 2020

@MOTORIST 👋

Did you try putting the service name at the last entry of options.commandOptions?
If this doesn't do the trick:

Would you mind sending a PR including a test?

container should be service

export const rm = function (options?: IDockerComposeOptions, service?: string): Promise<IDockerComposeResult>;

Maybe it might make sense to allow 1..n services to be rmed.

@Steveb-p Thoughts/Comments?

@Steveb-p
Copy link
Contributor

Sure, why not.

export const rm = function (options?: IDockerComposeOptions, ...services: string[]): Promise<IDockerComposeResult>;

or

export const rm = function (options?: IDockerComposeOptions, services: string | string[]): Promise<IDockerComposeResult>;

or

export const rm = function (options?: IDockerComposeOptions, services: string[]): Promise<IDockerComposeResult>;

depending on your preference.

Destructuring seems more docker-compose-like. Allows passing a single-string service or multiple without requiring internal type checks in function. All we will need to check is if services.length > 0.

@MOTORIST
Copy link
Author

MOTORIST commented Apr 22, 2020

Did you try putting the service name at the last entry of options.commandOptions

No, this not expected behavior

Maybe?

export const rmOne = function (service: string, options?: IDockerComposeOptions): Promise<IDockerComposeResult>

@Steveb-p suggested a more flexible solution.

@AlexZeitler
Copy link
Contributor

I would prefer the destructuring approach.

@Steveb-p
Copy link
Contributor

There were not tests against rm function actually. Also, commandOptions have to have "-s", otherwise running containers will not be stopped.

@AlexZeitler
Copy link
Contributor

@Steveb-p thanks for your PR. 📦 docker-compose@0.23.4 is released on npm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants