initcmd

package
v0.23.6 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDir      = "."
	DefaultTemplate = "standard"
)

Variables

This section is empty.

Functions

func Run

func Run(o Opt) error

Run keeps the existing API.

Types

type Action

type Action string
const (
	ActionCreate    Action = "create"
	ActionOverwrite Action = "overwrite"
	ActionAppend    Action = "append"
	ActionSkip      Action = "skip"
)

type BuiltinTemplates

type BuiltinTemplates struct{}

func (BuiltinTemplates) Find

func (BuiltinTemplates) Find(name string) (template, bool)

func (BuiltinTemplates) List

func (BuiltinTemplates) List() []template

func (BuiltinTemplates) Names

func (BuiltinTemplates) Names() []string

func (BuiltinTemplates) Width

func (BuiltinTemplates) Width() int

type Command

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

Command runs the init command with injectable dependencies.

func New

func New() *Command

func (*Command) Run

func (c *Command) Run(o Opt) error

type FS

type FS interface {
	Stat(string) (fs.FileInfo, error)
	MkdirAll(string, fs.FileMode) error
	ReadFile(string) ([]byte, error)
	WriteFile(string, []byte, fs.FileMode) error
	CreateTemp(string, string) (TempFile, error)
	Rename(string, string) error
	Remove(string) error
}

type OSFS

type OSFS struct{}

func (OSFS) CreateTemp

func (OSFS) CreateTemp(d, pat string) (TempFile, error)

func (OSFS) MkdirAll

func (OSFS) MkdirAll(p string, m fs.FileMode) error

func (OSFS) ReadFile

func (OSFS) ReadFile(p string) ([]byte, error)

func (OSFS) Remove

func (OSFS) Remove(p string) error

func (OSFS) Rename

func (OSFS) Rename(a, b string) error

func (OSFS) Stat

func (OSFS) Stat(p string) (fs.FileInfo, error)

func (OSFS) WriteFile

func (OSFS) WriteFile(p string, b []byte, m fs.FileMode) error

type Opt

type Opt struct {
	Dir         string
	Template    string
	Force       bool
	DryRun      bool
	NoGitignore bool
	List        bool
	Out         io.Writer
}

Opt describes how the init command should run. Fields are plain values so callers can map flags directly.

type TempFile

type TempFile interface {
	io.Writer
	Name() string
	Chmod(fs.FileMode) error
	Sync() error
	Close() error
}

type TemplateStore

type TemplateStore interface {
	Find(name string) (template, bool)
	List() []template
	Names() []string
	Width() int
}

Jump to

Keyboard shortcuts

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