cli

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package cli contains implementations of CLI commands. The command code is supposed contain only logic specific to the CLI and delegate complex/reusable stuff to code in /internal/commands. Commands in cli package should print results in human-readable format to stdout.

Index

Constants

View Source
const (
	CheckOK = CheckResultType(iota)
	CheckErr
)
View Source
const DefaultListSeparator = ","

Variables

View Source
var ErrInvalidArgs = errors.New("invalid arguments")
View Source
var TmcVersion = "n/a"

Functions

func AttachmentDelete

func AttachmentDelete(ctx context.Context, spec model.RepoSpec, tmNameOrId, attachmentName string) error

func AttachmentFetch

func AttachmentFetch(ctx context.Context, spec model.RepoSpec, tmNameOrId, attachmentName string) error

func AttachmentImport

func AttachmentImport(ctx context.Context, spec model.RepoSpec, tmNameOrId, filename string, mediaType string, force bool) error

func AttachmentList

func AttachmentList(ctx context.Context, spec model.RepoSpec, tmNameOrId string) error

func CalcFileDigest

func CalcFileDigest(filename string) error

func CheckIndex

func CheckIndex(ctx context.Context, spec model.RepoSpec) error

func CheckResources

func CheckResources(ctx context.Context, spec model.RepoSpec, names []string) error

func Copy

func Copy(ctx context.Context, repo model.RepoSpec, toRepo model.RepoSpec, search *model.SearchParams, opts repos.ImportOptions) error

func CreateSearchParamsFromCLI

func CreateSearchParamsFromCLI(flags FilterFlags, name string) *model.SearchParams

func Delete

func Delete(ctx context.Context, repo model.RepoSpec, id string) error

func Export

func Export(ctx context.Context, repo model.RepoSpec, search *model.SearchParams, outputPath string, restoreId bool, withAttachments bool) error

func Fetch

func Fetch(ctx context.Context, repo model.RepoSpec, idOrName, outputPath string, restoreId bool) error

func Index

func Index(ctx context.Context, spec model.RepoSpec) error

func List

func List(ctx context.Context, repo model.RepoSpec, search *model.SearchParams) error

func ListVersions

func ListVersions(ctx context.Context, spec model.RepoSpec, name string) error

func RepoAdd

func RepoAdd(name, typ, confStr, confFile, descr string) error

func RepoList

func RepoList() error

func RepoRemove

func RepoRemove(name string) error

func RepoRename

func RepoRename(oldName, newName string) (err error)

func RepoSetAuth

func RepoSetAuth(name, kind, data string) error

func RepoSetConfig

func RepoSetConfig(name, typ, confStr, confFile string, descr string) error

func RepoShow

func RepoShow(name string) error

func RepoToggleEnabled

func RepoToggleEnabled(name string) error

func Serve

func Serve(host, port string, opts ServeOptions, repo model.RepoSpec) error

func Stderrf

func Stderrf(format string, args ...any)

Stderrf prints a message to os.Stderr, followed by newline

func ValidateFile

func ValidateFile(filename string) error

Types

type CheckResult

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

func (CheckResult) String

func (r CheckResult) String() string

type CheckResultType

type CheckResultType int

func (CheckResultType) String

func (t CheckResultType) String() string

type FilterFlags

type FilterFlags struct {
	FilterAuthor       string
	FilterManufacturer string
	FilterMpn          string
	Search             string
}

type ImportExecutor

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

func NewImportExecutor

func NewImportExecutor(now commands.Now) *ImportExecutor

func (*ImportExecutor) Import

func (p *ImportExecutor) Import(ctx context.Context, filename string, spec model.RepoSpec, optTree bool, opts repos.ImportOptions) ([]repos.ImportResult, error)

Import imports file or directory into the specified repository Returns the list of import results up to the first encountered error, and the error

type ServeOptions

type ServeOptions struct {
	UrlCtxRoot string
	cors.CORSOptions
	jwt.JWTValidationOpts
	JWTValidation bool
}

Jump to

Keyboard shortcuts

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