Skip to content

Program provides a common entrypoint for CLI-based applications using di.

License

Notifications You must be signed in to change notification settings

livebud/program

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Program

Go Reference

Program provides a common entrypoint for CLI-based applications using di.

Install

go get github.com/livebud/program

Example

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/livebud/cli"
	"github.com/livebud/di"
	"github.com/livebud/program"
)

// Provide an arbitrary CLI that implements `cli.Parser`.
func provideCLI(in di.Injector) (cli.Parser, error) {
	cli := cli.New("cli", "some cli")
	cmd := cli.Command("say", "say hello")
	cmd.Run(func(ctx context.Context) error {
		fmt.Println("hello")
		return nil
	})
	return cli, nil
}

func main() {
	in := di.New()
	di.Provide[cli.Parser](in, provideCLI)
	os.Exit(program.Run(in))
}

Contributors

License

MIT

About

Program provides a common entrypoint for CLI-based applications using di.

Resources

License

Stars

Watchers

Forks

Packages

No packages published