Added some shit into paths util. Should delete later.
This commit is contained in:
parent
da2a5042e9
commit
29b71aa353
3 changed files with 19 additions and 7 deletions
|
@ -3,7 +3,7 @@
|
||||||
MKINCDIR = $(MKINCDIR)
|
MKINCDIR = $(MKINCDIR)
|
||||||
|
|
||||||
EXEDIR = $(HOME)/exe
|
EXEDIR = $(HOME)/exe
|
||||||
APPDIR = $(HOME)/app
|
APPDIR = `goblin paths -fr $HOME/app`
|
||||||
SHRDIR = $(HOME)/shr
|
SHRDIR = $(HOME)/shr
|
||||||
INCDIR = $SHRDIR/inc
|
INCDIR = $SHRDIR/inc
|
||||||
OBJDIR = $SHRDIR/obj
|
OBJDIR = $SHRDIR/obj
|
||||||
|
|
|
@ -7,6 +7,7 @@ install-sh:VQ: build
|
||||||
fi
|
fi
|
||||||
if test -d app ; then
|
if test -d app ; then
|
||||||
echo Installing application files...
|
echo Installing application files...
|
||||||
|
echo "'$HOME'"
|
||||||
echo "'$APPDIR'"
|
echo "'$APPDIR'"
|
||||||
echo `goblin paths app/* $APPDIR/$PKG_NAME/`
|
echo `goblin paths app/* $APPDIR/$PKG_NAME/`
|
||||||
#goblin mkdir -p `goblin path $APPDIR/$PKG_NAME` && cp -rf `goblin paths app/* $APPDIR/$PKG_NAME/`
|
#goblin mkdir -p `goblin path $APPDIR/$PKG_NAME` && cp -rf `goblin paths app/* $APPDIR/$PKG_NAME/`
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/surdeus/goblin/src/pathx"
|
"github.com/surdeus/goblin/src/pathx"
|
||||||
)
|
)
|
||||||
|
@ -19,26 +20,34 @@ var (
|
||||||
"ext": path.Ext,
|
"ext": path.Ext,
|
||||||
"dir": path.Dir,
|
"dir": path.Dir,
|
||||||
"all": func(v string) string { return v },
|
"all": func(v string) string { return v },
|
||||||
"fr": func(v string) string {
|
|
||||||
return pathx.FromReal(v).String()
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
handler func(string) string
|
handler func(string) string
|
||||||
r bool
|
r bool
|
||||||
|
fromReal bool
|
||||||
|
ec bool
|
||||||
noPartErr = errors.New("no such part")
|
noPartErr = errors.New("no such part")
|
||||||
)
|
)
|
||||||
|
|
||||||
func handlePath(p string) {
|
func handlePath(p string) {
|
||||||
|
if fromReal {
|
||||||
|
p = pathx.FromReal(p).String()
|
||||||
|
}
|
||||||
if handler != nil {
|
if handler != nil {
|
||||||
p = handler(p)
|
p = handler(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var toPrint string
|
||||||
if r {
|
if r {
|
||||||
pth := pathx.From(p)
|
toPrint = pathx.From(p).Real()
|
||||||
fmt.Println(pth.Real())
|
|
||||||
} else {
|
} else {
|
||||||
fmt.Println(p)
|
toPrint = p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ec {
|
||||||
|
toPrint = strings.ReplaceAll(toPrint, "\\", "\\\\")
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(toPrint)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Run(args []string) {
|
func Run(args []string) {
|
||||||
|
@ -47,6 +56,8 @@ func Run(args []string) {
|
||||||
flags := flag.NewFlagSet(arg0, flag.ExitOnError)
|
flags := flag.NewFlagSet(arg0, flag.ExitOnError)
|
||||||
flags.StringVar(&part, "p", "all", "part of path you want to print")
|
flags.StringVar(&part, "p", "all", "part of path you want to print")
|
||||||
flags.BoolVar(&r, "r", false, "print real OS dependent paths")
|
flags.BoolVar(&r, "r", false, "print real OS dependent paths")
|
||||||
|
flags.BoolVar(&fromReal, "fr", false, "take input paths as real ones")
|
||||||
|
flags.BoolVar(&ec, "ec", false, "escape characters (mostly for '\\' char in Git bash")
|
||||||
|
|
||||||
flags.Parse(args)
|
flags.Parse(args)
|
||||||
args = flags.Args()
|
args = flags.Args()
|
||||||
|
|
Loading…
Reference in a new issue