Documentation
¶
Overview ¶
A simple task runner for go (similar to packages like rake). It's a small wrapper around a `cobra` cli application, to create more flexible application build commands.
See the github page, https://github.com/mdev5000/runnr, for more details.
Example (RegisterThirdPartyCommands) ¶
package main import ( "context" "github.com/mdev5000/runnr" "github.com/spf13/cobra" ) func GetCommands() []*cobra.Command { first := &cobra.Command{ Use: "first", } second := &cobra.Command{ Use: "second", } return []*cobra.Command{first, second} } func main() { runner := runnr.NewRunner() // Register the third party commands under a root task called tp and exclude the "second" command. // // For example you would run the "first" command as follows: // runnr tp first // runner.Register(GetCommands).UnderParent("tp").Exclude("second") ctx := context.Background() if err := runner.Run(ctx); err != nil { panic(err) } }
Example (SettingsUpApplication) ¶
package main import ( "context" "fmt" "github.com/mdev5000/runnr" "github.com/spf13/cobra" ) func main() { runner := runnr.NewRunner() runner.AddCommand(&cobra.Command{ Use: "hello", RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("hello world") return nil }, }) ctx := context.Background() if err := runner.Run(ctx); err != nil { panic(err) } }
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandRegisterer ¶
Interface implemented by third parties to register tasks (tasks are basically just cobra comands).
type Registration ¶
type Registration interface { // Register all the commands under a parent task. UnderParent(parentCmdName string) Registration // Include only commands with the given names. Only(commandsNames ...string) Registration // Exclude command with the given names. Exclude(commandsNames ...string) Registration }
Controls the registration of a group of tasks. @todo add example for UnderParent
type Runner ¶
type Runner struct { InstanceName string // contains filtered or unexported fields }
func (*Runner) AddCommand ¶
func (*Runner) Register ¶
func (r *Runner) Register(registration CommandRegisterer) Registration
Click to show internal directories.
Click to hide internal directories.