scaffold

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2017 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConstructCallback

type ConstructCallback func(path string, dir, conflicted bool, status ConstructStatus)

ConstructCallback is called after files and directories is created

type ConstructConflictedCallback

type ConstructConflictedCallback func(path, oldContent, newContent string) bool

ConstructConflictedCallback is called when a new file content is diifferent from an existing file If it returns true, it overwrites a new one

type ConstructStatus

type ConstructStatus int

ConstructStatus represents a status of constructing processes

const (
	// ConstructSuccess is returned when constructing is succeeded
	ConstructSuccess ConstructStatus = iota + 1
	// ConstructSkipped is returned when constructing is skipped
	ConstructSkipped
	// ConstructFailed is returned when constructing is failed
	ConstructFailed
)

func (ConstructStatus) IsFailed

func (s ConstructStatus) IsFailed() bool

IsFailed returns true if a status represents failed

func (ConstructStatus) IsSkipped

func (s ConstructStatus) IsSkipped() bool

IsSkipped returns true if a status represents skipped

func (ConstructStatus) IsSuccess

func (s ConstructStatus) IsSuccess() bool

IsSuccess returns true if a status represents success

func (ConstructStatus) String

func (s ConstructStatus) String() string

type Directory

type Directory struct {
	Entry
	// contains filtered or unexported fields
}

Directory represents a directory entry of filesystem

func EmptyDirectory

func EmptyDirectory(path string) *Directory

EmptyDirectory returns an empty directory object

func NewDirectory

func NewDirectory(path string, entries []Entry) *Directory

NewDirectory returns a directory object

func (*Directory) Children

func (d *Directory) Children() map[string]Entry

Children returns child entries of this directory

func (*Directory) IsDir

func (d *Directory) IsDir() bool

IsDir returns true if this entry is a directory

type Entry

type Entry interface {
	Name() string
	Path() string
	IsDir() bool
	IsParentOf(other Entry) bool
	IsChildOf(other Entry) bool
}

Entry represents a filesystem entry

type File

type File struct {
	Entry
}

File represents a file entry of filesystem

func NewFile

func NewFile(path string) *File

NewFile returns a file object

type Meta

type Meta struct {
	Name     string
	Synopsis string
	Help     string
}

Meta is container for storing meta info of a scaffold

type MockRepository

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

MockRepository is a mock of Repository interface

func NewMockRepository

func NewMockRepository(ctrl *gomock.Controller) *MockRepository

NewMockRepository creates a new mock instance

func (*MockRepository) Construct

func (_m *MockRepository) Construct(scff Scaffold, name string, cb ConstructCallback, conflictedCb ConstructConflictedCallback) error

Construct mocks base method

func (*MockRepository) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockRepository) GetAll

func (_m *MockRepository) GetAll() ([]Scaffold, error)

GetAll mocks base method

type MockRepositoryMockRecorder

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

MockRepositoryMockRecorder is the mock recorder for MockRepository

func (*MockRepositoryMockRecorder) Construct

func (_mr *MockRepositoryMockRecorder) Construct(arg0, arg1, arg2, arg3 interface{}) *gomock.Call

Construct indicates an expected call of Construct

func (*MockRepositoryMockRecorder) GetAll

func (_mr *MockRepositoryMockRecorder) GetAll() *gomock.Call

GetAll indicates an expected call of GetAll

type MockScaffold

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

MockScaffold is a mock of Scaffold interface

func NewMockScaffold

func NewMockScaffold(ctrl *gomock.Controller) *MockScaffold

NewMockScaffold creates a new mock instance

func (*MockScaffold) EXPECT

func (_m *MockScaffold) EXPECT() *MockScaffoldMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockScaffold) Help

func (_m *MockScaffold) Help() string

Help mocks base method

func (*MockScaffold) Name

func (_m *MockScaffold) Name() string

Name mocks base method

func (*MockScaffold) Path

func (_m *MockScaffold) Path() string

Path mocks base method

func (*MockScaffold) Synopsis

func (_m *MockScaffold) Synopsis() string

Synopsis mocks base method

type MockScaffoldMockRecorder

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

MockScaffoldMockRecorder is the mock recorder for MockScaffold

func (*MockScaffoldMockRecorder) Help

func (_mr *MockScaffoldMockRecorder) Help() *gomock.Call

Help indicates an expected call of Help

func (*MockScaffoldMockRecorder) Name

func (_mr *MockScaffoldMockRecorder) Name() *gomock.Call

Name indicates an expected call of Name

func (*MockScaffoldMockRecorder) Path

func (_mr *MockScaffoldMockRecorder) Path() *gomock.Call

Path indicates an expected call of Path

func (*MockScaffoldMockRecorder) Synopsis

func (_mr *MockScaffoldMockRecorder) Synopsis() *gomock.Call

Synopsis indicates an expected call of Synopsis

type Repository

type Repository interface {
	GetAll() ([]Scaffold, error)
	Construct(
		scff Scaffold,
		name string,
		cb ConstructCallback,
		conflictedCb ConstructConflictedCallback,
	) error
}

Repository is a repository for scaffolds

type Scaffold

type Scaffold interface {
	Path() string
	Name() string
	Synopsis() string
	Help() string
}

Scaffold represents an executable subcommand

func NewScaffold

func NewScaffold(path string, meta *Meta) Scaffold

NewScaffold reeturns a new scaffold object

type Template

type Template interface {
	Compile(text string) (string, error)
}

Template is a template renderer for file paths and contents

func NewTemplate

func NewTemplate(name string) Template

NewTemplate creates a new template instance

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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