add debug mode

This commit is contained in:
jguer 2022-09-20 00:11:10 +02:00
parent e4fdc9a4d4
commit bc4732e9e1
No known key found for this signature in database
GPG key ID: 6D6CC9BEA8556B35
5 changed files with 22 additions and 6 deletions

View file

@ -274,7 +274,7 @@ func (installer *Installer) handleLayer(ctx context.Context,
}
}
fmt.Println(syncDeps, syncExp)
text.Debugln("syncDeps", syncDeps, "SyncExp", syncExp, "aurDeps", aurDeps, "aurExp", aurExp)
errShow := installer.installSyncPackages(ctx, cmdArgs, syncDeps, syncExp)
if errShow != nil {

View file

@ -65,6 +65,10 @@ func main() {
return
}
if config.Debug {
text.DebugMode = true
}
if errS := config.RunMigrations(
settings.DefaultMigrations(), config.Runtime.ConfigPath); errS != nil {
text.Errorln(errS)

View file

@ -30,6 +30,7 @@ var NoConfirm = false
// Configuration stores yay's config.
type Configuration struct {
Runtime *Runtime `json:"-"`
AURURL string `json:"aururl"`
BuildDir string `json:"buildDir"`
Editor string `json:"editor"`
@ -54,6 +55,7 @@ type Configuration struct {
RemoveMake string `json:"removemake"`
SudoBin string `json:"sudobin"`
SudoFlags string `json:"sudoflags"`
Version string `json:"version"`
RequestSplitN int `json:"requestsplitn"`
CompletionInterval int `json:"completionrefreshtime"`
MaxConcurrentDownloads int `json:"maxconcurrentdownloads"`
@ -73,9 +75,8 @@ type Configuration struct {
BatchInstall bool `json:"batchinstall"`
SingleLineResults bool `json:"singlelineresults"`
SeparateSources bool `json:"separatesources"`
Runtime *Runtime `json:"-"`
NewInstallEngine bool `json:"newinstallengine"`
Version string `json:"version"`
Debug bool `json:"debug"`
}
// SaveConfig writes yay config to file.
@ -224,6 +225,7 @@ func DefaultConfig(version string) *Configuration {
SeparateSources: true,
NewInstallEngine: false,
Version: version,
Debug: false,
}
}

View file

@ -18,7 +18,19 @@ const (
opSymbol = "::"
)
var cachedColumnCount = -1
var (
cachedColumnCount = -1
DebugMode = false
)
func Debugln(a ...interface{}) {
if !DebugMode {
return
}
fmt.Fprint(os.Stdout, append([]interface{}{Bold(yellow("[DEBUG] "))}, a...)...)
fmt.Fprintln(os.Stdout, ResetCode)
}
func OperationInfoln(a ...interface{}) {
fmt.Fprint(os.Stdout, append([]interface{}{Bold(Cyan(opSymbol + " ")), boldCode}, a...)...)

View file

@ -2,7 +2,6 @@ package main
import (
"context"
"fmt"
"os"
"path/filepath"
@ -33,7 +32,6 @@ func syncInstall(ctx context.Context,
}
topoSorted := graph.TopoSortedLayerMap()
fmt.Println(topoSorted, len(topoSorted))
preparer := &Preparer{
dbExecutor: dbExecutor,