command

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var TokenManager = hub.NewFileForHost

Functions

func Bin added in v0.1.0

func Bin(_ context.Context, ev Env) error

func Cleanup added in v0.0.4

func Cleanup(ev Env) error

func ConfigGet

func ConfigGet(cfg *env.Config, optionName string) error

func ConfigGetAll

func ConfigGetAll(_ Env, cfg *env.Config) error

func ConfigSet added in v0.0.4

func ConfigSet(ev Env, cfg *env.Config, optionName, optionValue string) error
Example
package main

import (
	"log"
	"os"
	"strings"

	"github.com/kyoh86/gordon/internal/command"
	"github.com/kyoh86/gordon/internal/env"
)

func main() {
	source := strings.NewReader(`
hooks:
  - /hook1
githubUser: userx1
githubHost: hostx1`)
	config, access, err := env.GetAppenv(source, env.EnvarPrefix)
	if err != nil {
		log.Fatalln(err)
	}
	if err := command.ConfigSet(&access, &config, "github.host", "hostx2"); err != nil {
		log.Fatalln(err)
	}
	if err := config.Save(os.Stdout); err != nil {
		log.Fatalln(err)
	}
	if err := command.ConfigGetAll(nil, &config); err != nil {
		log.Fatalln(err)
	}

}
Output:

hooks:
- /hook1
githubHost: hostx2
githubUser: userx1
hooks: /hook1
github.host: hostx2
github.user: userx1
github.token: *****
architecture:
os:
cache:
bin:
man:

func ConfigUnset

func ConfigUnset(ev Env, cfg *env.Config, optionName string) error
Example
package main

import (
	"log"
	"os"
	"strings"

	"github.com/kyoh86/gordon/internal/command"
	"github.com/kyoh86/gordon/internal/env"
)

func main() {
	source := strings.NewReader(`
hooks:
  - /hook1
githubUser: userx1
githubHost: hostx1`)
	config, access, err := env.GetAppenv(source, env.EnvarPrefix)
	if err != nil {
		log.Fatalln(err)
	}
	if err := command.ConfigUnset(&access, &config, "github.host"); err != nil {
		log.Fatalln(err)
	}
	if err := config.Save(os.Stdout); err != nil {
		log.Fatalln(err)
	}
	if err := command.ConfigGetAll(nil, &config); err != nil {
		log.Fatalln(err)
	}

}
Output:

hooks:
- /hook1
githubUser: userx1
hooks: /hook1
github.host:
github.user: userx1
github.token: *****
architecture:
os:
cache:
bin:
man:

func Dump added in v0.0.4

func Dump(ev Env, bundleFile string) error

func Get added in v0.0.4

func Get(ctx context.Context, ev Env, spec gordon.VersionSpec) error

func InitLog added in v0.0.4

func InitLog()

func Initialize added in v0.1.0

func Initialize(_ context.Context, ev Env) error

func Install added in v0.0.4

func Install(ctx context.Context, ev Env, spec gordon.VersionSpec) error

func Restore added in v0.0.4

func Restore(ctx context.Context, ev Env, bundle string) error

func Setup added in v0.0.9

func Setup(_ context.Context, ev Env, cfg *env.Config, force bool) error

func Uninstall added in v0.0.4

func Uninstall(ctx context.Context, ev Env, spec gordon.AppSpec) error

func Update added in v0.0.6

func Update(ctx context.Context, ev Env, spec gordon.AppSpec) error

func UpdateAll added in v0.1.8

func UpdateAll(ctx context.Context, ev Env) error

Types

type Env added in v0.0.4

type Env interface {
	Architecture() string
	Bin() string
	Cache() string
	GithubHost() string
	GithubUser() string
	Hooks() []string
	Man() string
	OS() string
}

Env is an interface generated for "github.com/kyoh86/gordon/internal/env.Access".

type HubClient added in v0.0.4

type HubClient interface {
	Asset(context.Context, *gogh.Repo, int64) (io.ReadCloser, error)
	LatestRelease(context.Context, *gogh.Repo) (*github.RepositoryRelease, error)
	Release(context.Context, *gogh.Repo, string) (*github.RepositoryRelease, error)
}

HubClient is an interface generated for "github.com/kyoh86/gordon/internal/hub.Client".

Jump to

Keyboard shortcuts

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