diff --git a/cmd/ddev/cmd/config-global.go b/cmd/ddev/cmd/config-global.go index f34e60eb52e..0b8d321eda7 100644 --- a/cmd/ddev/cmd/config-global.go +++ b/cmd/ddev/cmd/config-global.go @@ -7,6 +7,7 @@ import ( "strings" configTypes "github.com/ddev/ddev/pkg/config/types" + "github.com/ddev/ddev/pkg/fileutil" "github.com/ddev/ddev/pkg/globalconfig" globalconfigTypes "github.com/ddev/ddev/pkg/globalconfig/types" "github.com/ddev/ddev/pkg/nodeps" @@ -297,9 +298,9 @@ func init() { configGlobalCommand.Flags().BoolVarP(&instrumentationOptIn, "instrumentation-opt-in", "", false, "instrumentation-opt-in=true") configGlobalCommand.Flags().Bool("router-bind-all-interfaces", false, "router-bind-all-interfaces=true") configGlobalCommand.Flags().Int("internet-detection-timeout-ms", 3000, "Increase timeout when checking internet timeout, in milliseconds") - configGlobalCommand.Flags().Bool("disable-http2", false, "Optionally disable http2 in deprecated nginx-proxy ddev-router, 'ddev global --disable-http2' or `ddev global --disable-http2=false'") - configGlobalCommand.Flags().Bool("use-letsencrypt", false, "Enables experimental Let's Encrypt integration, 'ddev global --use-letsencrypt' or `ddev global --use-letsencrypt=false'") - configGlobalCommand.Flags().String("letsencrypt-email", "", "Email associated with Let's Encrypt, `ddev global --letsencrypt-email=me@example.com'") + configGlobalCommand.Flags().Bool("disable-http2", false, "Optionally disable http2 in deprecated nginx-proxy ddev-router, 'ddev config global --disable-http2' or `ddev config global --disable-http2=false'") + configGlobalCommand.Flags().Bool("use-letsencrypt", false, "Enables experimental Let's Encrypt integration, 'ddev config global --use-letsencrypt' or `ddev config global --use-letsencrypt=false'") + configGlobalCommand.Flags().String("letsencrypt-email", "", "Email associated with Let's Encrypt, `ddev config global --letsencrypt-email=me@example.com'") configGlobalCommand.Flags().Bool("simple-formatting", false, "If true, use simple formatting and no color for tables") configGlobalCommand.Flags().Bool("use-hardened-images", false, "If true, use more secure 'hardened' images for an actual internet deployment.") configGlobalCommand.Flags().Bool("fail-on-hook-fail", false, "If true, 'ddev start' will fail when a hook fails.") @@ -307,11 +308,11 @@ func init() { _ = configGlobalCommand.Flags().MarkDeprecated("mutagen-enabled", fmt.Sprintf("please use --%s instead", configTypes.FlagPerformanceModeName)) configGlobalCommand.Flags().String(configTypes.FlagPerformanceModeName, configTypes.FlagPerformanceModeDefault, configTypes.FlagPerformanceModeDescription(configTypes.ConfigTypeGlobal)) configGlobalCommand.Flags().Bool(configTypes.FlagPerformanceModeResetName, true, configTypes.FlagPerformanceModeResetDescription(configTypes.ConfigTypeGlobal)) - configGlobalCommand.Flags().String("table-style", "", "Table style for list and describe, see ~/.ddev/global_config.yaml for values") + configGlobalCommand.Flags().String("table-style", "", fmt.Sprintf("Table style for list and describe, see %s for values", fileutil.ShortHomeJoin(globalconfig.GetGlobalConfigPath()))) configGlobalCommand.Flags().String("required-docker-compose-version", "", "Override default docker-compose version (used only in development testing)") _ = configGlobalCommand.Flags().MarkHidden("required-docker-compose-version") configGlobalCommand.Flags().String("project-tld", "", "Override default project tld") - configGlobalCommand.Flags().Bool("use-docker-compose-from-path", true, "If true, use docker-compose from path instead of private ~/.ddev/bin/docker-compose (used only in development testing)") + configGlobalCommand.Flags().Bool("use-docker-compose-from-path", true, fmt.Sprintf("If true, use docker-compose from path instead of private %s (used only in development testing)", fileutil.ShortHomeJoin(globalconfig.GetDDEVBinDir(), "docker-compose"))) _ = configGlobalCommand.Flags().MarkHidden("use-docker-compose-from-path") configGlobalCommand.Flags().Bool("no-bind-mounts", true, "If true, don't use bind-mounts - useful for environments like remote Docker where bind-mounts are impossible") configGlobalCommand.Flags().String("xdebug-ide-location", "", "For less usual IDE locations specify where the IDE is running for Xdebug to reach it") diff --git a/pkg/ddevapp/list.go b/pkg/ddevapp/list.go index 57c8ae053f1..9d14c0189b6 100644 --- a/pkg/ddevapp/list.go +++ b/pkg/ddevapp/list.go @@ -4,6 +4,7 @@ import ( "bytes" "time" + "github.com/ddev/ddev/pkg/fileutil" "github.com/ddev/ddev/pkg/globalconfig" "github.com/ddev/ddev/pkg/nodeps" "github.com/ddev/ddev/pkg/output" @@ -74,7 +75,7 @@ func List(settings ListCommandSettings) { } router := globalconfig.DdevGlobalConfig.Router t.AppendFooter(table.Row{ - "Router", routerStatus, "~/.ddev", globalconfig.GetRouterURL(), router}, + "Router", routerStatus, fileutil.ShortHomeJoin(globalconfig.GetGlobalDdevDirLocation()), globalconfig.GetRouterURL(), router}, ) t.Render() output.UserOut.WithField("raw", appDescs).Print(out.String()) diff --git a/pkg/fileutil/files.go b/pkg/fileutil/files.go index 3fc858bf3d5..6d31b7b88f9 100644 --- a/pkg/fileutil/files.go +++ b/pkg/fileutil/files.go @@ -17,6 +17,7 @@ import ( "github.com/ddev/ddev/pkg/nodeps" "github.com/ddev/ddev/pkg/output" "github.com/ddev/ddev/pkg/util" + "github.com/sirupsen/logrus" ) // CopyFile copies the contents of the file named src to the file named @@ -539,3 +540,16 @@ func ExpandFilesAndDirectories(dir string, paths []string) ([]string, error) { } return expanded, nil } + +// ShortHomeJoin returns the same result as filepath.Join() path with $HOME/ replaced by ~/ +func ShortHomeJoin(elem ...string) string { + userHome, err := os.UserHomeDir() + if err != nil { + logrus.Fatalf("Could not get home directory for current user. Is it set? err=%v", err) + } + fullPath := filepath.Join(elem...) + if strings.HasPrefix(fullPath, userHome) { + return strings.Replace(fullPath, userHome, "~", 1) + } + return fullPath +}