-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First release of the kroki CLI #1
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you committed a main
binary.
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")) |
Oops 😅 |
cmd/convert.go
Outdated
} | ||
} | ||
|
||
func GraphFormatFromFile(filePath string) (result kroki.GraphFormat, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to name the return values, (kroki.GraphFormat, error)
is enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it was mandatory, removed!
Named return values is "just" for documentation purpose ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's for documentation, and you can use them to avoid returning the values: https://tour.golang.org/basics/7
@mcorbin I think we should use I think 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