Added the paths utility to convert paths.
This commit is contained in:
parent
68987038d4
commit
736532c65a
2 changed files with 40 additions and 0 deletions
|
@ -28,6 +28,7 @@ import(
|
|||
"github.com/surdeus/goblin/src/tool/path"
|
||||
"github.com/surdeus/goblin/src/tool/mk"
|
||||
"github.com/surdeus/goblin/src/tool/awk"
|
||||
"github.com/surdeus/goblin/src/tool/paths"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -58,6 +59,10 @@ func main() {
|
|||
"path" : mtool.Tool{path.Run, "print cross platform path based on cmd arguments"},
|
||||
"mk" : mtool.Tool{mk.Run, "file dependency system, simpler make"},
|
||||
"awk" : mtool.Tool{awk.Run, "simple scripting language for working with string templates"},
|
||||
"paths" : mtool.Tool{
|
||||
paths.Run,
|
||||
"convert UNIX slash separated paths into the OS compatible ones",
|
||||
},
|
||||
}
|
||||
|
||||
mtool.Main("goblin", tools)
|
||||
|
|
35
src/tool/paths/main.go
Normal file
35
src/tool/paths/main.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package paths
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"fmt"
|
||||
"flag"
|
||||
"bufio"
|
||||
"os"
|
||||
)
|
||||
|
||||
var (
|
||||
)
|
||||
|
||||
func handlePath(p string) {
|
||||
fin := filepath.FromSlash(p)
|
||||
fmt.Println(fin)
|
||||
}
|
||||
|
||||
func Run(args []string) {
|
||||
arg0 := args[0]
|
||||
args = args[1:]
|
||||
flags := flag.NewFlagSet(arg0, flag.ExitOnError)
|
||||
flags.Parse(args)
|
||||
args = flags.Args()
|
||||
|
||||
for _, p := range args {
|
||||
handlePath(p)
|
||||
}
|
||||
|
||||
rd := bufio.NewScanner(os.Stdin)
|
||||
for rd.Scan() {
|
||||
handlePath(rd.Text())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in a new issue