Open podhmo opened 2 years ago
maybe use translate package internally
if taking the action, definition is following.
type HelloOutput struct {
Message string `json: "message"`
}
type HelloInput struct {
Name string `json:"name"`
}
func Hello(ctx context.Context, logger *log.Logger, input HelloInput) (*HelloOutput, error) {
logger.Printf("hello")
return &HelloOutput{Message: "hello " + input.Name}, nil
}
If implements correctly, be able to run generated code, like something below.
$ hello -name foo
hello
{"message": "hello foo"}
But, but How should I handle primitive arguments (and primitive pointer arguments) ?
And how should I handling config for components ? (e.g. log.NewLogger()
's io.Writer and flags)
$ DEBUG=1 hello --data <(echo '{"name": "foo"}') --verbose 111
more simply, all value is passed by stdin.
$ echo '{"data": {"name": "foo"}, "verbose": true}' | hello -debug
like net/http handler, lift action to simple cli interface.