extensions

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2022 License: MIT Imports: 7 Imported by: 0

README

Bhojpur ISO - Extension Framework

It creates Git-like extensions for your Bhojpur ISO projects.

simple Usage

import "github.com/bhojpur/iso/pkg/manager/extensions"

// Detect my-awesome-cli-foo, my-awesome-cli-bar in $PATH and extensiopath1 (relative to the bin)
// it also accepts abspath
exts := extensions.Discover("my-awesome-cli", "extensiopath1", "extensiopath2")

fmt.Println("Detected extensions:", exts)

for _, ex := range exts {
  name := ex.Short()
  cobraCmd := ex.CobraCommand()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RelativeToCwd

func RelativeToCwd(p string) (string, error)

Types

type Extension

type Extension struct {
	AbsPath   string
	ShortName string
}

func (Extension) CobraCommand

func (e Extension) CobraCommand() *cobra.Command

func (Extension) Exec

func (e Extension) Exec(args []string) error

Execs an extension. It allows a multi-platform switch in the future

func (Extension) Path

func (e Extension) Path() string

func (Extension) Short

func (e Extension) Short() string

func (Extension) String

func (e Extension) String() string

type ExtensionInterface

type ExtensionInterface interface {
	String() string
	Path() string
	Short() string
	CobraCommand() *cobra.Command
	Exec(args []string) error
}

func Discover

func Discover(project string, extensionpath ...string) []ExtensionInterface

Discover returns extensions found in the paths specified and in PATH Extensions must start with the project tag (e.g. 'myawesomecli-' )

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL