generated from snivilised/arcadia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dff5509
commit 6d3b6d3
Showing
6 changed files
with
191 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
package proxy | ||
|
||
import ( | ||
"github.com/snivilised/cobrass" | ||
"github.com/snivilised/cobrass/src/clif" | ||
"github.com/snivilised/extendio/collections" | ||
) | ||
|
||
// 3rd party arguments provider: ad-hoc/profile/scheme | ||
// ad-hoc: all on the fly arguments | ||
// profile: ad-hoc and profile | ||
// scheme: adhoc and profile from a scheme | ||
// | ||
|
||
type baseRunner struct { | ||
shared *SharedRunnerInfo | ||
} | ||
|
||
func (r *baseRunner) profileSequence( | ||
name, itemPath string, | ||
) Sequence { | ||
changed := r.shared.Inputs.ParamSet.Native.ThirdPartySet.LongChangedCL | ||
cl := r.composeProfileCL(name, changed) | ||
step := &magickStep{ | ||
// fileManager | ||
program: r.shared.program, | ||
thirdPartyCL: cl, | ||
sourcePath: itemPath, | ||
// outputPath: , | ||
// journalPath: , | ||
} | ||
|
||
return Sequence{step} | ||
} | ||
|
||
func (r *baseRunner) schemeSequence( | ||
name, itemPath string, | ||
) Sequence { | ||
changed := r.shared.Inputs.ParamSet.Native.ThirdPartySet.LongChangedCL | ||
scheme := r.shared.sampler.Schemes[name] | ||
sequence := make(Sequence, 0, len(scheme.Profiles)) | ||
|
||
for _, currentProfileName := range scheme.Profiles { | ||
cl := r.composeProfileCL(currentProfileName, changed) | ||
step := &magickStep{ | ||
// fileManager | ||
program: r.shared.program, | ||
thirdPartyCL: cl, | ||
sourcePath: itemPath, | ||
// outputPath: , | ||
// journalPath: , | ||
} | ||
|
||
sequence = append(sequence, step) | ||
} | ||
|
||
return sequence | ||
} | ||
|
||
func (r *baseRunner) adhocSequence( | ||
itemPath string, | ||
) Sequence { | ||
changed := r.shared.Inputs.ParamSet.Native.ThirdPartySet.LongChangedCL | ||
step := &magickStep{ | ||
// fileManager | ||
program: r.shared.program, | ||
thirdPartyCL: changed, | ||
sourcePath: itemPath, | ||
// outputPath: , | ||
// journalPath: , | ||
} | ||
|
||
return Sequence{step} | ||
} | ||
|
||
func (r *baseRunner) composeProfileCL( | ||
profileName string, | ||
secondary clif.ThirdPartyCommandLine, | ||
) clif.ThirdPartyCommandLine { | ||
primary := r.shared.profiles[profileName] | ||
|
||
return cobrass.Evaluate( | ||
primary, | ||
r.shared.Inputs.ParamSet.Native.ThirdPartySet.KnownBy, | ||
secondary, | ||
) | ||
} | ||
|
||
func (r *baseRunner) Run(sequence Sequence) error { | ||
var ( | ||
zero Step | ||
resultErr error | ||
) | ||
|
||
iterator := collections.ForwardRunIt[Step, error](sequence, zero) | ||
each := func(s Step) error { | ||
return s.Run() | ||
} | ||
while := func(_ Step, err error) bool { | ||
if resultErr == nil { | ||
resultErr = err | ||
} | ||
|
||
// this needs to change according to a new, not yet defined | ||
// setting, 'ContinueOnError' | ||
// | ||
return err == nil | ||
} | ||
|
||
iterator.RunAll(each, while) | ||
|
||
return resultErr | ||
} | ||
|
||
func (r *baseRunner) Reset() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package proxy | ||
|
||
import ( | ||
"github.com/snivilised/cobrass" | ||
"github.com/snivilised/extendio/xfs/nav" | ||
) | ||
|
||
type FullRunner struct { | ||
baseRunner | ||
} | ||
|
||
func (r *FullRunner) OnNewShrinkItem(item *nav.TraverseItem, | ||
positional []string, | ||
thirdPartyCL cobrass.ThirdPartyCommandLine, | ||
) error { | ||
_ = item | ||
_ = positional | ||
_ = thirdPartyCL | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package proxy | ||
|
||
import ( | ||
"github.com/snivilised/extendio/xfs/nav" | ||
) | ||
|
||
type SamplerRunner struct { | ||
baseRunner | ||
} | ||
|
||
func (r *SamplerRunner) OnNewShrinkItem(item *nav.TraverseItem, | ||
positional []string, | ||
) error { | ||
_ = positional | ||
|
||
// foreach profileName inside the scheme: | ||
// start off with (*r.shared.profilesCFG)[blurProfile] => copy into another map: current | ||
// foreach args in secondary | ||
// if secondary arg not present in current, add to current | ||
// if secondary arg not present in current, if not already in current | ||
// --- | ||
// - at end, we end up with a map(current) that contains profileName args combined with present | ||
// - add the current to end of positional to create a clif.ThirdPartyCommandLine: useCL | ||
// to achieve this Overlay needs the KnownBy collection the same way Evaluate does; | ||
// the reason is although we can limit the flags specified inside the config to be | ||
// of their long forms, the arguments present on the command line must be free to be | ||
// either long or short forms, therefore we, need to be able to recognise if a short form | ||
// flag in present is actually in present in the config as its long form. | ||
// | ||
profileName := r.shared.Inputs.Root.ProfileFam.Native.Profile | ||
schemeName := r.shared.Inputs.Root.ProfileFam.Native.Scheme | ||
|
||
var sequence Sequence | ||
|
||
switch { | ||
case profileName != "": | ||
sequence = r.profileSequence(profileName, item.Path) | ||
|
||
case schemeName != "": | ||
sequence = r.schemeSequence(schemeName, item.Path) | ||
|
||
default: | ||
sequence = r.adhocSequence(item.Path) | ||
} | ||
|
||
return r.Run(sequence) | ||
} |