I would like to create a gh module that basically runs github cli (gh) with the string as the arguments. However if i create a function that just receives an string it won't work because it would use it as if it was argv[1] :
package main
import "context"
type Gh struct{}
// Returns a container that runs the `gh` command with the given arguments.
func (m *Gh) Cli(
ctx context.Context,
// The arguments to pass to the `gh` command.
// +required
command string,
// The GitHub token to use for authentication.
// +required
gh_token *Secret,
) *Container {
gh := dag.Container().From("v17v3/gh")
// Set the GitHub token as an environment variable.
token, err := gh_token.Plaintext(ctx)
if err != nil {
panic(err)
}
gh.WithEnvVariable("GH_TOKEN", token)
return gh.WithExec([]string{command})
}
Splitting the arg by spaces does not sound cool because they may could be set like arg=foo and reinventing the wheel by creating a function for each subparameter sounds like a bad idea.
Maybe this is not a desirable approach for dagger?