modules

package
v0.0.0-...-e5c115e Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry registers bar modules. It can be used to easily register modules until an error is encountered and pass them to `barista.Run`. Modules from registry appear in the bar in the same order as they were added.

registry := modules.NewRegistry()

registry.
    Add(someModule, someOtherModule).
    Addf(func() (bar.Module, error) {
        return someModuleFromFactory, nil
    })

if err := registry.Err(); err != nil {
  panic(err)
}

panic(barista.Run(registry.Modules()...))

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new *Registry for bar modules.

func (*Registry) Add

func (r *Registry) Add(modules ...bar.Module) *Registry

Add adds modules to the registry. Modules that are nil are ignored. If a factory func passed to `Addf` previously returned an error, adding modules here is a no-op.

func (*Registry) Addf

func (r *Registry) Addf(factory func() (bar.Module, error)) *Registry

Addf adds a module using a factory func. If the factory returns a nil module, it is ignored. Errors returned by the factory will cause the registry to not accept any more modules via `Add` or `Addf`.

func (*Registry) Err

func (r *Registry) Err() error

Err returns the first error returned by a factory func or nil if there was none.

func (*Registry) Modules

func (r *Registry) Modules() []bar.Module

Modules returns the bar modules. This can be used to pass modules directly to `barista.Run`.

Directories

Path Synopsis
ip
yay
Package yay contains an updates.Provider that uses `yay` to check for Arch Linux package updates.
Package yay contains an updates.Provider that uses `yay` to check for Arch Linux package updates.
weather

Jump to

Keyboard shortcuts

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