Simplified system command
This commit is contained in:
parent
21017e6378
commit
1cee7fcaa0
@ -8,33 +8,39 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
Executable string
|
||||
Root string
|
||||
Library string
|
||||
Executable string
|
||||
Root string
|
||||
Library string
|
||||
WorkingDirectory string
|
||||
)
|
||||
|
||||
func init() {
|
||||
debug.SetGCPercent(-1)
|
||||
executable, err := os.Executable()
|
||||
|
||||
var err error
|
||||
Executable, err = os.Executable()
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Executable = executable
|
||||
Root = filepath.Dir(executable)
|
||||
WorkingDirectory, err = os.Getwd()
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Root = filepath.Dir(Executable)
|
||||
Library = filepath.Join(Root, "lib")
|
||||
stat, err := os.Stat(Library)
|
||||
|
||||
if !os.IsNotExist(err) && stat != nil && stat.IsDir() {
|
||||
return
|
||||
if os.IsNotExist(err) || stat == nil || !stat.IsDir() {
|
||||
findLibrary()
|
||||
}
|
||||
}
|
||||
|
||||
dir, err := os.Getwd()
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
func findLibrary() {
|
||||
dir := WorkingDirectory
|
||||
|
||||
for {
|
||||
Library = path.Join(dir, "lib")
|
||||
|
@ -2,35 +2,22 @@ package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
|
||||
"git.akyoto.dev/cli/q/src/build/config"
|
||||
)
|
||||
|
||||
// System shows system information.
|
||||
func System(args []string) int {
|
||||
line := "%-19s%s\n"
|
||||
|
||||
fmt.Printf(line, "Platform:", runtime.GOOS)
|
||||
fmt.Printf(line, "Architecture:", runtime.GOARCH)
|
||||
fmt.Printf(line, "Go:", runtime.Version())
|
||||
|
||||
// Directory
|
||||
directory, err := os.Getwd()
|
||||
|
||||
if err == nil {
|
||||
fmt.Printf(line, "Directory:", directory)
|
||||
} else {
|
||||
fmt.Printf(line, "Directory:", err.Error())
|
||||
}
|
||||
|
||||
// Compiler
|
||||
executable, err := os.Executable()
|
||||
|
||||
if err == nil {
|
||||
fmt.Printf(line, "Compiler:", executable)
|
||||
} else {
|
||||
fmt.Printf(line, "Compiler:", err.Error())
|
||||
}
|
||||
fmt.Printf(line, "Directory:", config.WorkingDirectory)
|
||||
fmt.Printf(line, "Compiler:", config.Executable)
|
||||
fmt.Printf(line, "Library:", config.Library)
|
||||
fmt.Printf(line, "Threads:", strconv.Itoa(runtime.NumCPU()))
|
||||
|
||||
return 0
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user