docker-compose icon indicating copy to clipboard operation
docker-compose copied to clipboard

Streamline the all, many, one commands

Open gautaz opened this issue 3 years ago • 1 comments

Hello,

Thanks for helping us use compose through Node.JS :-).

Looking at the API, I was wondering why many functions are tripled with All, Many and One instead of using a TS signature close to command(services?: string | string[], options?).

I am not fluent in TS, I basically use plain JS for my day to day programming so I might be wrong...

I was also wondering why there is no pushOne or pushMany.

gautaz avatar Aug 13 '21 07:08 gautaz

TypeScript is similar to JavaScript. After all, it's a superset of it.

Commands being split like that help detect issues while writing code. While one could argue that One is variation of Many, where you pass an array containing only a single element (kinda), All removes any ambiguity in the initial argument (does empty array mean all services, or none? Maybe null means all?).

Other than that, there is no specific reason. It was easier to write them like that, since then there was no need for any logic inside that would handle the cases.

I'm not sure about push though :sweat_smile:

Steveb-p avatar Aug 13 '21 08:08 Steveb-p

Spring cleaning time! I completely forgot to close this one, doing it now as the PR has been merged for quite some time now.

gautaz avatar Apr 21 '24 20:04 gautaz