mirror of https://github.com/docker/compose.git
Keep --workdir at compose level for retro compatibility
This also checks for conflicts with --project-directory at `docker compose` command level Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
This commit is contained in:
parent
bc234bdcdf
commit
98bb20f2d1
|
@ -17,8 +17,12 @@
|
||||||
package compose
|
package compose
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/compose-spec/compose-go/cli"
|
"github.com/compose-spec/compose-go/cli"
|
||||||
"github.com/compose-spec/compose-go/types"
|
"github.com/compose-spec/compose-go/types"
|
||||||
|
"github.com/morikuni/aec"
|
||||||
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
|
|
||||||
|
@ -32,6 +36,7 @@ type projectOptions struct {
|
||||||
ProjectName string
|
ProjectName string
|
||||||
Profiles []string
|
Profiles []string
|
||||||
ConfigPaths []string
|
ConfigPaths []string
|
||||||
|
WorkDir string
|
||||||
ProjectDir string
|
ProjectDir string
|
||||||
EnvFile string
|
EnvFile string
|
||||||
}
|
}
|
||||||
|
@ -42,6 +47,8 @@ func (o *projectOptions) addProjectFlags(f *pflag.FlagSet) {
|
||||||
f.StringArrayVarP(&o.ConfigPaths, "file", "f", []string{}, "Compose configuration files")
|
f.StringArrayVarP(&o.ConfigPaths, "file", "f", []string{}, "Compose configuration files")
|
||||||
f.StringVar(&o.EnvFile, "env-file", "", "Specify an alternate environment file.")
|
f.StringVar(&o.EnvFile, "env-file", "", "Specify an alternate environment file.")
|
||||||
f.StringVar(&o.ProjectDir, "project-directory", "", "Specify an alternate working directory\n(default: the path of the Compose file)")
|
f.StringVar(&o.ProjectDir, "project-directory", "", "Specify an alternate working directory\n(default: the path of the Compose file)")
|
||||||
|
f.StringVar(&o.WorkDir, "workdir", "", "DEPRECATED! USE --project-directory INSTEAD.\nSpecify an alternate working directory\n(default: the path of the Compose file)")
|
||||||
|
_ = f.MarkHidden("workdir")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *projectOptions) toProjectName() (string, error) {
|
func (o *projectOptions) toProjectName() (string, error) {
|
||||||
|
@ -98,6 +105,13 @@ func Command(contextType string) *cobra.Command {
|
||||||
Use: "compose",
|
Use: "compose",
|
||||||
TraverseChildren: true,
|
TraverseChildren: true,
|
||||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
if opts.WorkDir != "" {
|
||||||
|
if opts.ProjectDir != "" {
|
||||||
|
return errors.New(aec.Apply(`cannot specify DEPRECATED "--workdir" and "--project-directory". Please use only "--project-directory" instead.`, aec.RedF))
|
||||||
|
}
|
||||||
|
opts.ProjectDir = opts.WorkDir
|
||||||
|
fmt.Println(aec.Apply(`option "--workdir" is DEPRECATED at root level! Please use "--project-directory" instead.`, aec.RedF))
|
||||||
|
}
|
||||||
if contextType == store.DefaultContextType || contextType == store.LocalContextType {
|
if contextType == store.DefaultContextType || contextType == store.LocalContextType {
|
||||||
Warning = "The new 'docker compose' command is currently experimental. " +
|
Warning = "The new 'docker compose' command is currently experimental. " +
|
||||||
"To provide feedback or request new features please open issues at https://github.com/docker/compose-cli"
|
"To provide feedback or request new features please open issues at https://github.com/docker/compose-cli"
|
||||||
|
|
Loading…
Reference in New Issue