refactor and add some stuff
This commit is contained in:
parent
77faccc29f
commit
3ab1b112ce
14
commander.go
Normal file
14
commander.go
Normal file
@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func execute(cmdstr string) (string, error) {
|
||||
cmdargs := strings.Split(cmdstr, " ") // string arrayified
|
||||
cmd := cmdargs[0] // command
|
||||
cmdargs = append(cmdargs[:0], cmdargs[1:]...) // argument array sans cmd
|
||||
out, err := exec.Command(cmd, cmdargs...).CombinedOutput()
|
||||
return string(out[:]), err
|
||||
}
|
26
filer.go
Normal file
26
filer.go
Normal file
@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// for generating the project blanks
|
||||
func createFile(fpath string) bool {
|
||||
fl, err := newFile(fpath)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
return false
|
||||
}
|
||||
fl.Close()
|
||||
return true
|
||||
}
|
||||
|
||||
// in case we need a file we can edit
|
||||
func newFile(fpath string) (*os.File, error) {
|
||||
if err := os.MkdirAll(filepath.Dir(fpath), 0770); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return os.Create(fpath)
|
||||
}
|
5
go.mod
5
go.mod
@ -1,6 +1,3 @@
|
||||
module projector
|
||||
module bitbucket.org/gmgauthier_ecs/projector
|
||||
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
)
|
||||
|
15
main.go
15
main.go
@ -1,4 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
wd, _ := os.Getwd()
|
||||
dirlist, _ := os.ReadDir(wd)
|
||||
fmt.Println(wd)
|
||||
for _, item := range dirlist {
|
||||
if os.DirEntry.IsDir(item) {
|
||||
fmt.Println(wd + "/" + os.DirEntry.Name(item) + "/")
|
||||
} else {
|
||||
fmt.Println(wd + "/" + os.DirEntry.Name(item))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user