Reorganized file structure

This commit is contained in:
Eduard Urbach 2024-06-10 15:51:39 +02:00
parent 8b595ef3ce
commit 722d07c321
Signed by: eduard
GPG key ID: 49226B848C78F6C8
57 changed files with 431 additions and 614 deletions

View file

@ -1,11 +1,11 @@
package cli
import (
"fmt"
"strings"
"git.akyoto.dev/cli/q/src/build"
"git.akyoto.dev/cli/q/src/config"
"git.akyoto.dev/cli/q/src/log"
"git.akyoto.dev/cli/q/src/build/config"
)
// Build builds an executable.
@ -22,7 +22,7 @@ func Build(args []string) int {
default:
if strings.HasPrefix(args[i], "-") {
log.Error.Printf("Unknown parameter: %s\n", args[i])
fmt.Printf("Unknown parameter: %s\n", args[i])
return 2
}
@ -33,7 +33,7 @@ func Build(args []string) int {
err := b.Run()
if err != nil {
log.Error.Println(err)
fmt.Println(err)
return 1
}

View file

@ -1,14 +1,12 @@
package cli
import (
"git.akyoto.dev/cli/q/src/log"
)
import "fmt"
// Help shows the command line argument usage.
func Help(args []string) int {
log.Error.Println("Usage: q [command] [options]")
log.Error.Println("")
log.Error.Println(" build [directory]")
log.Error.Println(" system")
fmt.Println("Usage: q [command] [options]")
fmt.Println("")
fmt.Println(" build [directory]")
fmt.Println(" system")
return 2
}

View file

@ -2,21 +2,13 @@ package cli_test
import (
"fmt"
"io"
"os"
"testing"
"git.akyoto.dev/cli/q/src/cli"
"git.akyoto.dev/cli/q/src/log"
"git.akyoto.dev/go/assert"
)
func TestMain(m *testing.M) {
log.Info.SetOutput(io.Discard)
log.Error.SetOutput(io.Discard)
os.Exit(m.Run())
}
func TestCLI(t *testing.T) {
type cliTest struct {
arguments []string

View file

@ -1,36 +1,35 @@
package cli
import (
"fmt"
"os"
"runtime"
"git.akyoto.dev/cli/q/src/log"
)
// System shows system information.
func System(args []string) int {
line := "%-19s%s\n"
log.Info.Printf(line, "Platform:", runtime.GOOS)
log.Info.Printf(line, "Architecture:", runtime.GOARCH)
log.Info.Printf(line, "Go:", runtime.Version())
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 {
log.Info.Printf(line, "Directory:", directory)
fmt.Printf(line, "Directory:", directory)
} else {
log.Info.Printf(line, "Directory:", err.Error())
fmt.Printf(line, "Directory:", err.Error())
}
// Compiler
executable, err := os.Executable()
if err == nil {
log.Info.Printf(line, "Compiler:", executable)
fmt.Printf(line, "Compiler:", executable)
} else {
log.Info.Printf(line, "Compiler:", err.Error())
fmt.Printf(line, "Compiler:", err.Error())
}
return 0