@@ -112,6 +112,15 @@ func TestRootHomeFlagOverridesHelpDescription(t *testing.T) {
112112 assertPathUnderRoot (t , path , home , "config" , "config.json" )
113113}
114114
115+ func TestRootHomeFlagAppliesBeforeSubcommandHelp (t * testing.T ) {
116+ setTestConfigHome (t )
117+
118+ err := Execute ([]string {"config" , "--home" , "relative" , "--help" })
119+ if err == nil || ! strings .Contains (err .Error (), "--home" ) {
120+ t .Fatalf ("expected --home error, got %v" , err )
121+ }
122+ }
123+
115124func helpConfigPath (out string ) string {
116125 for _ , line := range strings .Split (out , "\n " ) {
117126 line = strings .TrimSpace (line )
@@ -161,6 +170,11 @@ func TestRootHomePreScanSkipsGlobalFlagValues(t *testing.T) {
161170 if ! ok || home != "/tmp/gog" {
162171 t .Fatalf ("home=%q ok=%t, want /tmp/gog true" , home , ok )
163172 }
173+
174+ home , ok = preScanHomeArg ([]string {"config" , "--home" , "/tmp/gog" , "--help" })
175+ if ! ok || home != "/tmp/gog" {
176+ t .Fatalf ("home=%q ok=%t, want /tmp/gog true" , home , ok )
177+ }
164178}
165179
166180func TestRootHomeFlagRejectsRelativePath (t * testing.T ) {
0 commit comments