diff options
author | Flu0r1ne <flur01ne@flu0r1ne.net> | 2021-09-03 00:02:31 -0500 |
---|---|---|
committer | Flu0r1ne <flur01ne@flu0r1ne.net> | 2021-09-03 00:02:31 -0500 |
commit | 287d029975b7718109f81b480079f375f7d8700a (patch) | |
tree | 2324f902ebc59ffda5afa2e7506e3fa0ac9b51b3 /stddirs.go | |
parent | d078f6dc10eb265a5d88cd96adf86173d6d3ba2e (diff) | |
download | planr-287d029975b7718109f81b480079f375f7d8700a.tar.xz planr-287d029975b7718109f81b480079f375f7d8700a.zip |
Add clean option and fix issue with dir propegation
Diffstat (limited to 'stddirs.go')
-rw-r--r-- | stddirs.go | 41 |
1 files changed, 20 insertions, 21 deletions
@@ -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 } |