T
Taskโ€ข3y ago
leaanthony

Embedding the CLI

I'm looking at using task as the main task orchestrator for Wails v3. I've been looking at the options for task.Executor and have something reasonable up and running. Ideally, I'd like to give Wails users the full power of the task CLI so have looked at what it might mean to "pass through" the cli args to the current task cli main method. The only issues I can see are an internal logger package and tricking Cobra into trimming the first arg out. So the options seem to be: 1. Hack the current task cli main method so I can call it with pass through args 2. Reimplement the main method and try to keep parity with task releases 3. Create a public method in task that accepts a []string of args that gets processed by Cobra which external apps can hook into Just wondering what your recommendation might be. Thanks ๐Ÿ‘ PS: I'm aware this is a very specialist request so "you're on your own" is a valid response ๐Ÿ˜‚
1 Reply
andreynering
andreyneringโ€ข3y ago
Hi @leaanthony! This has a bit of history... There was a time when it was impossible to import task packages because they were intentionally put inside an internal directory. A few people kept asking for support to use Task as a library, so I eventually allowed it but told people that compatibility could break with time, even without a major version bump. I'm not opposed to improve its support further, by moving the content of the main package to another importable package and a custom args []string argument if that helps. That said, keep in mind we're actually currently using pflag and not cobra, but the user @Jeremie-Chauvel said he intents to work on the migration to Cobra because of the completion generation support. See: https://github.com/go-task/task/issues/293 I'd wait for that first to avoid any code conflicts. If you want to help him with it, you may want to ping him in this issue.
GitHub
Add generate-completion command ยท Issue #293 ยท go-task/task
This is follow-up for #103. Example: task generate-completion --bash >> ~/.bashrc

Did you find this page helpful?