cli

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: Apache-2.0 Imports: 29 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 (
	OutputFormatJSON  = "json"
	OutputFormatPlain = "plain"
)
View Source
const DefaultListSeparator = ","

Variables

View Source
var ErrInvalidArgs = errors.New("invalid arguments")
View Source
var ErrInvalidOutputFormat = errors.New("invalid output format")

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, concat bool, outputPath string) error

func AttachmentImport

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

func AttachmentList

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

func CalcFileDigest

func CalcFileDigest(filename string) error

func CheckIntegrity added in v0.1.3

func CheckIntegrity(ctx context.Context, spec model.RepoSpec, args []string, format string) error

func Copy

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

func CreateSearchIndex added in v0.1.3

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

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.Filters, outputPath string, restoreId bool, withAttachments bool, format string) 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 IsValidOutputFormat added in v0.1.3

func IsValidOutputFormat(format string) bool

func List

func List(ctx context.Context, repo model.RepoSpec, search *model.Filters, format string) error

func ListVersions

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

func RepoAdd

func RepoAdd(name, typ string, locStr, descr, jsonConf, confFile string) error

func RepoList

func RepoList(format string) error

func RepoRemove

func RepoRemove(name string) error

func RepoRename

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

func RepoSetAuth

func RepoSetAuth(name, kind string, data []string) error

func RepoSetConfig

func RepoSetConfig(name, locStr, jsonConf, confFile string) error

func RepoSetDescription added in v0.1.3

func RepoSetDescription(ctx context.Context, name, description string) error

func RepoSetHeaders added in v0.1.3

func RepoSetHeaders(name string, data []string) error

func RepoShow

func RepoShow(name string) error

func RepoToggleEnabled

func RepoToggleEnabled(name string) error
func Search(ctx context.Context, repo model.RepoSpec, query, format 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(ctx context.Context, filename string) error

Types

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, format string) ([]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 ListResultEntry added in v0.1.3

type ListResultEntry struct {
	Name         string `json:"name"`
	Author       string `json:"author"`
	Manufacturer string `json:"manufacturer"`
	MPN          string `json:"mpn"`
	Repo         string `json:"repo"`
}

type OpResultType added in v0.1.3

type OpResultType int

func (OpResultType) MarshalJSON added in v0.1.3

func (t OpResultType) MarshalJSON() ([]byte, error)

func (OpResultType) String added in v0.1.3

func (t OpResultType) String() string

type OperationResult added in v0.1.3

type OperationResult struct {
	Type       OpResultType `json:"type"`
	ResourceId string       `json:"resourceId"`
	Text       string       `json:"text,omitempty"`
}

func (OperationResult) String added in v0.1.3

func (r OperationResult) String() string

type RepoConfigAbridged added in v0.1.3

type RepoConfigAbridged struct {
	Name        string `json:"name"`
	Type        string `json:"type"`
	Enabled     bool   `json:"enabled"`
	Location    string `json:"location"`
	Description string `json:"description,omitempty"`
}

type SearchResultEntry added in v0.1.3

type SearchResultEntry struct {
	TMID        string             `json:"tmid"`
	Repo        string             `json:"repo"`
	SearchMatch *model.SearchMatch `json:"searchMatch,omitempty"`
}

type ServeOptions

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

type VersionResultEntry added in v0.1.3

type VersionResultEntry struct {
	Version     string `json:"version"`
	Description string `json:"description,omitempty"`
	Repo        string `json:"repo"`
	ID          string `json:"id"`
}

Jump to

Keyboard shortcuts

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