wip: add split packages support

This commit is contained in:
2025-02-03 19:15:54 +03:00
parent 606cd5473a
commit 8978cc2855
16 changed files with 1282 additions and 743 deletions

View File

@ -197,6 +197,27 @@ func (d *Decoder) GetFuncP(name string, prepare PrepareFunc) (ScriptFunc, bool)
}, true
}
// TODO: replace
func (d *Decoder) GetFuncSub(name string) (
func(ctx context.Context, opts ...interp.RunnerOption) (*interp.Runner, error), bool,
) {
fn := d.getFunc(name)
if fn == nil {
return nil, false
}
return func(ctx context.Context, opts ...interp.RunnerOption) (*interp.Runner, error) {
sub := d.Runner.Subshell()
for _, opt := range opts {
err := opt(sub)
if err != nil {
return nil, err
}
}
return sub, sub.Run(ctx, fn)
}, true
}
func (d *Decoder) getFunc(name string) *syntax.Stmt {
names, err := overrides.Resolve(d.info, overrides.DefaultOpts.WithName(name))
if err != nil {