open

package
v0.24.1 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: MIT Imports: 10 Imported by: 0

README

POSH open provider

Define and open common URL from the posh.

Usage

Plugin
package main

type Plugin struct {
  l        log.Logger
  op       *onepassword.OnePassword
  cache    cache.Cache
  commands command.Commands
}

func New(l log.Logger) (plugin.Plugin, error) {
  var err error
  inst := &Plugin{
    l:        l,
    cache:    &cache.MemoryCache{},
    commands: command.Commands{},
  }

  // ...

  inst.op, err = onepassword.New(l, inst.cache)
  if err != nil {
    return nil, errors.Wrap(err, "failed to create onepassword")
  }

	// ...

  inst.commands.MustAdd(open.NewCommand(l, inst.op))

  // ...

  return inst, nil
}
Config
## Open
open:
  homepage:
    description: Home page
    routes:
      home:
        path: https://www.foomo.org/
        description: Home
      imprint:
        path: https://www.foomo.org/imprint
        description: Imprint
        basicAuth:
          item: xxxxxxxxxxxxxxxxxxxxxxxxxx
          vault: xxxxxxxxxxxxxxxxxxxxxxxxxx
          account: foomo

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

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

func NewCommand

func NewCommand(l log.Logger, op *onepassword.OnePassword, opts ...CommandOption) (*Command, error)

func (*Command) Complete

func (c *Command) Complete(ctx context.Context, r *readline.Readline) []goprompt.Suggest

func (*Command) Description

func (c *Command) Description() string

func (*Command) Execute

func (c *Command) Execute(ctx context.Context, r *readline.Readline) error

func (*Command) Help

func (c *Command) Help(ctx context.Context, r *readline.Readline) string

func (*Command) Name

func (c *Command) Name() string

func (*Command) Validate

func (c *Command) Validate(ctx context.Context, r *readline.Readline) error

type CommandOption

type CommandOption func(*Command)

func CommandWithName

func CommandWithName(v string) CommandOption

func WithConfigKey

func WithConfigKey(v string) CommandOption

type Config

type Config map[string]ConfigRouter

type ConfigRoute

type ConfigRoute struct {
	Path        string              `yaml:"path"`
	Description string              `yaml:"description"`
	BasicAuth   *onepassword.Secret `yaml:"basicAuth"`
}

type ConfigRouter

type ConfigRouter struct {
	URL         string                 `yaml:"url"`
	Routes      map[string]ConfigRoute `yaml:"routes"`
	Description string                 `yaml:"description"`
}

Jump to

Keyboard shortcuts

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