Hacker News new | ask | show | jobs
by llmblockchain 817 days ago
I do this as well, but I pass two main arguments to my main executable task, and args. For example:

go run cmd/server/main.go --task db --args migrate

go run cmd/server/main.go --task cron --args reset-trial-accounts

etc.

1 comments

I use https://github.com/spf13/cobra religiously for this kind of thing - it handles all the annoying corner cases of parsing flags, and also has an intuitive notion of subcommands (with basic usage/help text generated) for picking which task you want to run with positional arguments.
I'll have to mess with it and see. It looks like it could make the general CLI ux better :)