@@ -441,13 +441,14 @@ func (ctx *Context) Populate(cmd *Command, all, overwrite bool) error {
441441 case g .Type == HookT , g .Def == nil && ! all :
442442 continue
443443 case g .Def != nil :
444- var err error
445- if value , err = ctx . Expand ( g . Def ); err != nil {
446- return err
444+ v , err := ctx . Expand ( g . Def )
445+ if err != nil {
446+ return fmt . Errorf ( "populate %s: cannot expand %v (%T): %w" , g . Name , g . Def , g . Def , err )
447447 }
448+ value , _ = asString [string ](v )
448449 }
449450 if err := ctx .Vars .Set (ctx , g , value , false ); err != nil {
450- return fmt .Errorf ("cannot populate %s with %q : %w" , g .Name , value , err )
451+ return fmt .Errorf ("populate %s: %w" , g .Name , err )
451452 }
452453 }
453454 return nil
@@ -469,10 +470,10 @@ func (ctx *Context) Populate(cmd *Command, all, overwrite bool) error {
469470// $CONFIG_TYPE{KEY} - the registered config file loader type and key value, for example: `$YAML{my_key}`, `$TOML{my_key}`
470471//
471472// TODO: finish implementation for $CONFIG_TYPE, expand anywhere in string
472- func (ctx * Context ) Expand (v any ) (string , error ) {
473+ func (ctx * Context ) Expand (v any ) (any , error ) {
473474 s , ok := v .(string )
474475 if ! ok {
475- return asString [ string ]( v )
476+ return v , nil
476477 }
477478 if ctx .Override != nil {
478479 if s , ok := ctx .Override [s ]; ok {
@@ -524,7 +525,7 @@ func (ctx *Context) Expand(v any) (string, error) {
524525 }
525526 s , err := f ()
526527 if err != nil {
527- return "" , fmt .Errorf ("unable to expand %q: %w" , s , err )
528+ return "" , fmt .Errorf ("expand %q: %w" , v , err )
528529 }
529530 return s , nil
530531}
0 commit comments