CLI flags can be order sensitive

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the dumb-mistakes-and-gotchas category.

Last Updated: 2024-04-25

Some clis require flags/arguments strictly follow certain commands or subcommands - i.e. a flag may work in one position but fail (or have another meaning) in another.

e.g. this failed (at time of writing)

$ docker-compose up mysql -f docker-compose-development.yml -f docker-compose.yml up

whereas this works

# Difference: -f flag immediately after main binary name, `docker-compose`
# instead of nested deeper into the command.
$ docker-compose -f docker-compose-development.yml -f docker-compose.yml up mysql

Basically the -f flags for config files must be after the docker-compose command and not the arguments (up mysql, in this case).