3 ms·
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
by llmblockchain 3y 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.
- GeneralMayhem 3y agoI use https://github.com/spf13/cobra 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.
- llmblockchain 3y agoI'll have to mess with it and see. It looks like it could make the general CLI ux better :)