Closed ggrossetie closed 5 years ago
You could avoid global variables by defining the flags in the command:
var convertCmd = &cobra.Command{
Use: "convert file",
Short: "Convert text diagram to image",
Flags: []cli.Flag{
cli.StringFlag{
Name: "config",
Usage: "description",
// use Value: "foo" for default values
}
},
And then:
config := (cmd.String("config"))
you committed a
main
binary.
Oops :sweat_smile:
@mcorbin I think we should use io.Reader
and io.Writer
abstraction to read the diagram source and write the result.
It's also easier to test as you can replace the Reader
and/or the Writer
with a Buffer
.
I think kroki-go
should provide the following functions:
func (c *Client) FromReader(reader io.Reader, diagramType DiagramType, imageFormat ImageFormat) (string, error) {}
func (c *Client) Write(writer io.Writer, result string) error {}
@mcorbin Should be ready to go.
After this pull request is merged, I will make a few changes to kroki-go then release a new version and adjust the CLI code.
Usage
By default the output format is
svg
and the diagram type is inferred from the file name. The above command is equivalent to:Read from stdin, output to stdout and use
svg
as the default output format.Read from stdin, output to out.png and use
png
as output format.Read the file hello.dot and output to out.png.
Read the file hello.dot and output to stdout.
TODO
KROKI_ENDPOINT
$HOME/kroki.yml
/etc/kroki.yml
kroki.yml
--config /path/to/kroki.yml
out-file