Overwrite parent commands PreRun code for `compose version`

.. to avoid trying (and failing) to load a compose file if the COMPOSE_FILE env var is set such as `COMPOSE_FILE=foo compose version`

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
This commit is contained in:
Laura Brehm 2022-08-01 11:37:54 +02:00
parent 70ccc98f17
commit c9876f4c66
1 changed files with 5 additions and 0 deletions

View File

@ -42,6 +42,11 @@ func versionCommand() *cobra.Command {
runVersion(opts)
return nil
},
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
// overwrite parent PersistentPreRunE to avoid trying to load
// compose file on version command if COMPOSE_FILE is set
return nil
},
}
// define flags for backward compatibility with com.docker.cli
flags := cmd.Flags()