fs

package
v0.0.0-...-a7a3610 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PluginStructure = Dir{
	"DragonInfo.toml": File{},
	"commands": Dir{
		"init.lua": File{},
	},
	"server": Dir{
		"init.lua": File{},
	},
	"client": Dir{
		"init.lua": File{},
	},
	"views": Dir{},
}

PluginStructure represents what a plugin is intended to look like.

View Source
var ProjectStructure = Dir{
	"Dragonfile.toml": File{},
	".gitignore":      File{},
	"plugins":         Dir{},
	"commands": Dir{
		"init.lua": File{},
	},
	"server": Dir{
		"init.lua": File{},
	},
	"client": Dir{
		"init.lua": File{},
	},
	"views": Dir{},
}

ProjectStructure is a skeleton of what a `DragonMUD` project should look like after `dragon init` is called.

Functions

func CreateFromStructure

func CreateFromStructure(params CreateStructureParams) error

CreateFromStructure takes in an fs.Item and generates the filesystem records (files and directories) according the structure provided. This is a recursive operation, calling itself for all instances of ItemTypeDir.

Types

type CreateStructureParams

type CreateStructureParams struct {
	Log          logger.Log
	BaseName     string
	Structure    Item
	TemplateData interface{}
}

CreateStructureParams makes it easier and more meaningful to call CreateFromStructure.

type Dir

type Dir map[string]Item

Dir is a map of Items. This allows you to define in a simplified way complex (or simple) file structure.

func (Dir) Create

func (d Dir) Create(log logger.Log, fpath string, td interface{})

Create defines how how a directory is to be created, which is simply creating the directory and then calling CreateFromStructure with the directory.

func (Dir) Type

func (Dir) Type() ItemType

Type for Dir returns ItemTypeDir.

type File

type File struct{}

File wraps a string and represents a file with that name in the given location on the file system.

func (File) Create

func (File) Create(log logger.Log, fpath string, templateData interface{})

Create will create the file with asset data for the given file name.

func (File) Type

func (File) Type() ItemType

Type for File returns ItemTypeFile.

type Item

type Item interface {
	Type() ItemType
	Create(logger.Log, string, interface{})
}

Item is an interface that both File and Dir implement.

type ItemType

type ItemType uint8

ItemType represents the kind of item, such as a File or Directory

const (
	ItemTypeFile ItemType = 1 + iota
	ItemTypeDir
)

Item types

Jump to

Keyboard shortcuts

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