core

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2025 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Copyright 2023 the u-root Authors. All rights reserved Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Copyright 2023 the u-root Authors. All rights reserved Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Package core provides an interface and basic funcionalities for the core utils implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

type Base struct {
	Stdin      io.Reader
	Stdout     io.Writer
	Stderr     io.Writer
	WorkingDir string
	LookupEnv  LookupEnvFunc
}

Base is a struct that holds common fields for commands.

func (*Base) Getenv

func (b *Base) Getenv(key string) string

Getenv is a helper to retrieve an environment variable value without the extra bool return.

func (*Base) Init

func (b *Base) Init()

Init initializes the Base command with default values.

func (*Base) ResolvePath

func (b *Base) ResolvePath(path string) string

ResolvePath resolves a path relative to the working directory.

func (*Base) SetIO

func (b *Base) SetIO(stdin io.Reader, stdout io.Writer, stderr io.Writer)

SetIO sets the input/output streams for the command.

func (*Base) SetLookupEnv

func (b *Base) SetLookupEnv(lookupEnv LookupEnvFunc)

SetLookupEnv sets the function used to look up environment variables.

func (*Base) SetWorkingDir

func (b *Base) SetWorkingDir(workingDir string)

SetWorkingDir sets the working directory for the command.

type Command

type Command interface {
	SetIO(stdin io.Reader, stdout io.Writer, stderr io.Writer)
	SetWorkingDir(workingDir string)
	SetLookupEnv(lookupEnv LookupEnvFunc)
	Run(args ...string) error
	RunContext(ctx context.Context, args ...string) error
}

Command is an interface that defines the methods for executing a command.

type LookupEnvFunc

type LookupEnvFunc func(string) (string, bool)

LookupEnvFunc is a function type that looks up an environment variable.

Directories

Path Synopsis
Package base64 implements the base64 core utility.
Package base64 implements the base64 core utility.
Package cat implements the cat core utility.
Package cat implements the cat core utility.
Package chmod implements the chmod core utility.
Package chmod implements the chmod core utility.
Package cp implements the cp core utility.
Package cp implements the cp core utility.
Package find implements the find core utility.
Package find implements the find core utility.
Package gzip implements the gzip command.
Package gzip implements the gzip command.
Package ls implements the ls core utility.
Package ls implements the ls core utility.
Package mkdir implements the mkdir core utility.
Package mkdir implements the mkdir core utility.
Package mktemp implements the mktemp core utility.
Package mktemp implements the mktemp core utility.
Package mv implements the mv core utility.
Package mv implements the mv core utility.
Package rm implements the rm core utility.
Package rm implements the rm core utility.
Package shasum implements the shasum core utility.
Package shasum implements the shasum core utility.
Package tar implements the tar command.
Package tar implements the tar command.
Package touch implements the touch core utility.
Package touch implements the touch core utility.
Package xargs implements the xargs core utility.
Package xargs implements the xargs core utility.

Jump to

Keyboard shortcuts

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