Our great sponsors
-
ascii-image-converter
A cross-platform command-line tool to convert images into ascii art and print them on the console. Now supports braille art!
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
Also check GitHubs comminuty guidelines for projects ( https://github.com/TheZoraiz/ascii-image-converter/community ) for at least the contributing guide.
I'm using the cobra library to implement command-line functionality. All the flags are handed in cmd/root.go in this function.
I think it is probably just a matter of personal taste, but I like to handle params and flags on the main function. I am probably biased by C experience and using https://github.com/alecthomas/kong though. Kong is certainly not as popular as cobra, but its approach.
To piggyback on GoReleaser I would recommend a few extra bits. Automated documentation of CLI using the cobra docs gen https://github.com/spf13/cobra/blob/master/doc/md\_docs.md, consider a CHANGELOG.md to track all changes over time ( self promotion https://github.com/miniscruff/changie which integrates with goreleaser ). Use github actions to automate all of the release processes.
Related posts
- Building and distributing a command line tool in Golang
- climate "CLI Mate": a CLI library that autogenerates CLIs from structs / functions with support for nested subcommands, global / local flags, help generation from godocs, typo suggestions, shell completion and more
- Which packages do you recommend for building cli tools?
- K3S Binary, How does that work?
- GoConsole: New Update! thanks all of you for your advice and your help.