Closed Pantani closed 1 month ago
I am not sure if this is very useful. What is the use case?
If you want to parse the output of a flag from the command into the hooks, for instance, if you create a hook for the chain build
command, you can get the --output
flag passed to the command. Or, if you want to extend the chain build
command, having a new flag, like --run-tests
to run tests after the build.
Alright, but how will an app use that?
For instance, if you want to add a flag to the chain build command to run tests after the build:
func (app) Manifest(context.Context) (*plugin.Manifest, error) {
return &plugin.Manifest{
Name: "hooks",
Hooks: []*plugin.Hook{
{
Name: "chain-build",
PlaceHookOn: "ignite chain build",
Flags: []*plugin.Flag{
{
Name: "run-test",
Usage: "Run tests after build",
DefaultValue: "false",
Type: plugin.FlagTypeString,
},
},
},
},
Commands: cmd.GetCommands(),
}, nil
}
func (app) ExecuteHookPost(_ context.Context, hook *plugin.ExecutedHook, _ plugin.ClientAPI) error {
var (
flags = hook.Hook.Flags
runTests = flags.GetBool("run-test")
)
if runTests != "" {
tests.Run()
}
return nil
}
And now you can use ignite chain build --run-test
and run tests after build, or maybe you have a plugin to generate something like front-end code as a chain build hook. You can create a flag to pass the path or also a flag to enable the generation.
Like that, I get it better now. Is it, however, really something we want to allow? I really like that hooks are just logic running before/after/always-after regardless of the flags. This adds granularity, sure, but imho worsen a bit the UX.
Do we actually already need this feature for something?
Discussed on Slack. I get it and it makes sense to add the feature.
I am not sure if this is very useful. What is the use case?