Added file scanner
This commit is contained in:
parent
fc2600c796
commit
16690d390f
10 changed files with 178 additions and 71 deletions
|
@ -1,21 +1,18 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"git.akyoto.dev/cli/q/src/build"
|
||||
"git.akyoto.dev/cli/q/src/log"
|
||||
)
|
||||
|
||||
// Build builds an executable.
|
||||
func Build(args []string) int {
|
||||
directory := "."
|
||||
b := build.New(".")
|
||||
|
||||
if len(args) > 0 {
|
||||
directory = args[0]
|
||||
}
|
||||
|
||||
b := build.New(directory)
|
||||
|
||||
for i := 1; i < len(args); i++ {
|
||||
for i := 0; i < len(args); i++ {
|
||||
switch args[i] {
|
||||
case "--dry":
|
||||
b.WriteExecutable = false
|
||||
|
@ -24,12 +21,24 @@ func Build(args []string) int {
|
|||
b.Verbose = true
|
||||
|
||||
default:
|
||||
log.Error.Printf("Unknown parameter: %s\n", args[i])
|
||||
return 2
|
||||
if strings.HasPrefix(args[i], "-") {
|
||||
log.Error.Printf("Unknown parameter: %s\n", args[i])
|
||||
return 2
|
||||
}
|
||||
|
||||
b.Directory = args[i]
|
||||
}
|
||||
}
|
||||
|
||||
err := b.Run()
|
||||
fullPath, err := filepath.Abs(b.Directory)
|
||||
|
||||
if err != nil {
|
||||
log.Error.Println(err)
|
||||
return 1
|
||||
}
|
||||
|
||||
b.Directory = fullPath
|
||||
err = b.Run()
|
||||
|
||||
if err != nil {
|
||||
log.Error.Println(err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue