aboutsummaryrefslogtreecommitdiff
path: root/stddirs.go
diff options
context:
space:
mode:
Diffstat (limited to 'stddirs.go')
-rw-r--r--stddirs.go41
1 files changed, 20 insertions, 21 deletions
diff --git a/stddirs.go b/stddirs.go
index 14776d8..2385529 100644
--- a/stddirs.go
+++ b/stddirs.go
@@ -66,22 +66,22 @@ func dirFromEnv(name, env string) *string {
return nil
}
-func (c *DirConfig) SetSrcDir(srcDir string) {
+func (c *DirConfig) SetSrc(srcDir string) {
dieDirAbsent("src", srcDir)
c.src = srcDir
}
-func (c *DirConfig) SetConfigDir(configDir string) {
+func (c *DirConfig) SetConfig(configDir string) {
dieDirAbsent("planr (config)", configDir)
c.config = configDir
}
-func (c *DirConfig) SetBuildDir(buildDir string) {
+func (c *DirConfig) SetBuild(buildDir string) {
dieDirAbsent("build", buildDir)
c.build = buildDir
}
-func (c *DirConfig) SetConfigDirFromTree(cdir string) {
+func (c *DirConfig) SetConfigFromTree(cdir string) {
var configDir string
found := traverseUp(cdir, func (path string) bool {
@@ -103,12 +103,11 @@ func (c *DirConfig) SetConfigDirFromTree(cdir string) {
}
}
-func (c DirConfig) ConfigDir() string {
+func (c DirConfig) Config() string {
if c.config != "" {
return c.config
}
-
if dir := dirFromEnv("config", ENV_CONFIG_DIR); dir != nil {
c.config = *dir
return c.config
@@ -122,7 +121,7 @@ func (c DirConfig) ConfigDir() string {
return c.config
}
-func (c DirConfig) SrcDir() string {
+func (c DirConfig) Src() string {
if c.src != "" {
return c.src
}
@@ -133,11 +132,11 @@ func (c DirConfig) SrcDir() string {
}
// set path relative to config
- dir := c.ConfigDir()
+ dir := c.Config()
return path.Join(dir, DEFAULT_PATH_SRC)
}
-func (c DirConfig) BuildDir() string {
+func (c DirConfig) Build() string {
if c.src != "" {
return c.src
}
@@ -147,38 +146,38 @@ func (c DirConfig) BuildDir() string {
return c.build
}
- dir := c.ConfigDir()
+ dir := c.Config()
return path.Join(dir, DEFAULT_PATH_BUILD)
}
-func (c DirConfig) CleanBuildDir() {
- build := c.BuildDir()
+func (c DirConfig) CleanBuild() {
+ build := c.Build()
if err := os.RemoveAll(build); err != nil {
log.Fatalf("Cannot build directory %v\n", err)
}
- if err := os.Remove(build); err != nil {
- log.Fatalf("Could not remove build directory %v\n", err)
- }
+ // if err := os.Remove(build); err != nil {
+ // log.Fatalf("Could not remove build directory %v\n", err)
+ // }
}
-func (c DirConfig) MkBuildDir() {
- build := c.BuildDir()
+func (c DirConfig) MkBuild() {
+ build := c.Build()
if err := os.Mkdir(build, 0755); err != nil {
log.Fatalf("Could not create build directory %v\n", err)
}
}
-func (c DirConfig) RubricDir() string {
- rubric := path.Join(c.ConfigDir(), "rubric")
+func (c DirConfig) Rubric() string {
+ rubric := path.Join(c.Config(), "rubric")
dieDirAbsent("rubric", rubric)
return rubric
}
-func (c DirConfig) TestsDir() string {
- tests := path.Join(c.ConfigDir(), "tests")
+func (c DirConfig) Tests() string {
+ tests := path.Join(c.Config(), "tests")
dieDirAbsent("tests", tests)
return tests
}