denvlib

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2015 License: MIT Imports: 14 Imported by: 0

README

denvelopment

Contributions

TODO

Development Notes

I still need to work through this part a bit

Resources

Denv requires a few static assets for sensible defaults. In order to accomodate this as well as not requiring Denv to have to depend on static paths, resources are included by generating them via the scripts/include.go routine. This should be a pre-build step and in go >= 1.4 is included via go generate. Older versions should run go run scripts/include.go before building to embed the assets. If a resource is changed (settings.yml) without running include.go beforehand, the changes will not take.

###DenvInfo

Maintains state

###DenvHome

Home dir for Denv to live in. Generally a hidden path in the users $HOME

###DenvIgnore

Do not keep file handles that match these patterns Similar to a .gitignore file

Documentation

Overview

denvlib provides the mechanics for the denv client. The denv client handles the hidden files in the users home directory which are generally configurations for the users environment.

A simple example use case is when doing Python and Go development on the same box. Python (PEP-8) wants 4 spaces for it's whereas Go likes actual tab characters. Being able to quickly switch between these by activating a denv solves this iise.

Each denv manages a particular environment and can be activated/deactived.

Denv definitions can be pushed/pulled from a remote git server

THIS FILE IS AUTOGENERATED FROM scripts/include.go EDITS WILL BE SQUISHED IT IS MEANT FOR HOLDING CONFIGURABLE OPTIONS

Index

Constants

View Source
const (
	Version = "123014f"
)

Variables

This section is empty.

Functions

func List

func List() map[*Denv]bool

Gets a map of the denvs currently on the system The returned map is meanted to be used like a set TODO: Make a ls denv -> files

func Pull

func Pull(remote string, branch string) string

Pull the contents of the remote/branch from the remote server onto the local system. If there are conflicts, they will need to be managed manually in ~/.denv This also makes denv scripts executable with chmod 744

func Push

func Push(url, branch, message string) string

Push the current contents of ~/.denv to a remote git server at the specified branch. If there are issues, they will need to be resolved manually with git @ ~/.denv

func UserHome

func UserHome() string

Types

type Config

type Config struct {
	DenvHome    string
	IgnoreFile  string
	InfoFile    string
	RestoreDenv string
	PreScript   string
	PostScript  string
}
var Settings Config

type Denv

type Denv struct {
	Path   string
	Ignore map[string]bool
}

func Activate

func Activate(env string) (*Denv, error)

Activate a denv by replacing hidden files in the users home directoty with those in the denv definition. as well as executing the scripts .denvpre in the denv definition If one is not already active, the current state of the users home directory will be stashed and restored whenever the user deactivates. Returns the denv that was activated, nil if there was an error

func Deactivate

func Deactivate() *Denv

Deactivate the current denv and restore it to the state. Also executes the denvs .denvpost scripts. before denv was active. Returns the name of the deactivated denv. Empty string if there was no denv to deactivate

func GetDenv

func GetDenv(name string) (*Denv, error)

Get a Denv that has already been created Nil, err if it hasn't been created yet

func NewDenv

func NewDenv(name string) *Denv

Create a new Denv Bootstrap the creation with the folder and default denvignore

func Snapshot

func Snapshot(name string) *Denv

Creates copies of the hidden files in the users home directory and puts them in a new denv definition in ~/.denv/name. The denv definition can be edited manually after. The default denvignore will be used.

func Which

func Which() *Denv

Returns the currently active Denv or nil

func (*Denv) Enter

func (d *Denv) Enter()

Copy the contents of the denv definition into the users home dir Also execute the PreScripts, before any copy is made

func (*Denv) Exit

func (d *Denv) Exit()

Run the PostScripts

func (*Denv) Files

func (d *Denv) Files() (included []string, ignored []string, scripts []string)

TODO add denv.AddFile(path) Paths of files in the Denv Definition Tells you which paths are currently included and ignored and which are scripts

func (*Denv) IsDenvFile

func (d *Denv) IsDenvFile(path string) bool

Check if this file is able to a be used by this denv

func (*Denv) IsIgnored

func (d *Denv) IsIgnored(path string) bool

Check to see if a file path be ignored by this Denv

func (*Denv) IsScript

func (d *Denv) IsScript(path string) bool

Check is the path is a script of this denv

func (*Denv) LoadIgnore

func (d *Denv) LoadIgnore()

Loads the denvignore from disk

func (*Denv) MatchedFiles

func (d *Denv) MatchedFiles(root string) (included []string, ignored []string, scripts []string)

Given an arbitrary path, return which files would be included and which would be ignored. If path contains a folder, it will not be recursed into. Returns the included, ignored and script files

func (*Denv) Name

func (d *Denv) Name() string

Name of the denv

func (*Denv) SetDenvIgnore

func (d *Denv) SetDenvIgnore(path string)

Explicitly set this denvs denvignore to the given path

func (*Denv) ToString

func (d *Denv) ToString() string

String representation of the denv

type DenvInfo

type DenvInfo struct {
	Current    *Denv
	Path       string
	Repository *git.Repository
}

DenvInfo is a mechanism for handling state of the denv environment. It flushed it's contents to disk and reads from a given location

var Info DenvInfo

func (*DenvInfo) Clear

func (d *DenvInfo) Clear()

func (*DenvInfo) Flush

func (d *DenvInfo) Flush()

func (*DenvInfo) IsActive

func (d *DenvInfo) IsActive() bool

func (*DenvInfo) Load

func (d *DenvInfo) Load()

func (*DenvInfo) ToString

func (d *DenvInfo) ToString() string

Jump to

Keyboard shortcuts

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