Merge branch 'master' of https://github.com/surdeus/goblin
This commit is contained in:
commit
5140f3591b
4 changed files with 26 additions and 11 deletions
|
@ -2,8 +2,8 @@
|
|||
|
||||
wd=`pwd`
|
||||
|
||||
cd src/cmd/goblin && go install && cd $wd
|
||||
cd $wd/src/cmd/goblin && go install && cd $wd
|
||||
|
||||
mkdir -p $HOME/app/goblin
|
||||
cp -rf app/* $HOME/app/goblin
|
||||
cp -rf $wd/app/* $HOME/app/goblin
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
type Value string
|
||||
type Path struct {
|
||||
Values []Value
|
||||
IsAbs bool
|
||||
}
|
||||
|
||||
func (p Path) Append(values ...string) Path {
|
||||
|
@ -22,7 +23,15 @@ func (p Path) Append(values ...string) Path {
|
|||
}
|
||||
|
||||
func From(p string) Path {
|
||||
ret := Path{}
|
||||
if len(p) == 0 {
|
||||
return ret
|
||||
}
|
||||
|
||||
p = path.Clean(p)
|
||||
if p[0] == '/' {
|
||||
ret.IsAbs = true
|
||||
}
|
||||
p, _ = strings.CutSuffix(p, "/")
|
||||
svalues := strings.Split(p, "/")
|
||||
|
||||
|
@ -30,10 +39,9 @@ func From(p string) Path {
|
|||
for i, s := range svalues {
|
||||
values[i] = Value(s)
|
||||
}
|
||||
ret.Values = values
|
||||
|
||||
return Path{
|
||||
Values: values,
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func (v Value) IsValid() bool {
|
||||
|
@ -45,12 +53,16 @@ func (v Value) Err() error {
|
|||
}
|
||||
|
||||
func (p Path) StringValues() []string {
|
||||
values := make([]string, len(p.Values))
|
||||
for i, v := range p.Values {
|
||||
values[i] = string(v)
|
||||
ret := []string{}
|
||||
if p.IsAbs {
|
||||
ret = append(ret, "/")
|
||||
}
|
||||
|
||||
return values
|
||||
for _, v := range p.Values {
|
||||
ret = append(ret, string(v))
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func (p Path) Real() string {
|
||||
|
|
|
@ -331,7 +331,6 @@ func Run(args []string) {
|
|||
mkincdir == "" {
|
||||
homeDir, _ := os.UserHomeDir()
|
||||
os.Setenv("MKINCDIR", homeDir + "/app/goblin/mk/inc" )
|
||||
fmt.Println("shit:", os.Getenv("MKINCDIR"))
|
||||
}
|
||||
|
||||
flags := flag.NewFlagSet(arg0, flag.ExitOnError)
|
||||
|
|
|
@ -163,7 +163,11 @@ func parseRedirInclude(p *parser, t token) parserStateFun {
|
|||
filename := ""
|
||||
//fmt.Printf("'%v'\n", p.tokenbuf)
|
||||
for i := range p.tokenbuf {
|
||||
filename += expand(p.tokenbuf[i].val, p.rules.vars, true)[0]
|
||||
filename += expand(
|
||||
p.tokenbuf[i].val,
|
||||
p.rules.vars,
|
||||
true,
|
||||
)[0]
|
||||
}
|
||||
file, err := os.Open(pathx.From(filename).Real())
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue