From a5d5d7d3250dc0bdb1088406ac51fe970054b0dc Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Tue, 2 Jul 2024 10:21:40 -0500 Subject: [PATCH] add debug flag --- pkgs/oizys/cmd/root.go | 5 ++++- pkgs/oizys/internal/oizys/main.go | 10 +++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pkgs/oizys/cmd/root.go b/pkgs/oizys/cmd/root.go index f5c4ec2..7d6ae62 100644 --- a/pkgs/oizys/cmd/root.go +++ b/pkgs/oizys/cmd/root.go @@ -31,6 +31,7 @@ func Execute() { var ( flake string host string + debug bool verbose bool nom bool systemPath bool @@ -42,7 +43,7 @@ var rootCmd = &cobra.Command{ Use: "oizys", Short: "nix begat oizys", PersistentPreRun: func(cmd *cobra.Command, args []string) { - if verbose { + if debug { log.Info("running with verbose mode") log.SetLevel(log.DebugLevel) } @@ -50,6 +51,7 @@ var rootCmd = &cobra.Command{ oizys.SetHost(host) oizys.SetVerbose(verbose) oizys.SetResetCache(resetCache) + oizys.SetDebug(debug) }, } @@ -76,5 +78,6 @@ func init() { rootCmd.PersistentFlags().StringVar(&flake, "flake", "", "path to flake ($OIZYS_DIR or $HOME/oizys)") rootCmd.PersistentFlags().StringVar(&host, "host", "", "host to build (current host)") rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "show verbose output") + rootCmd.PersistentFlags().BoolVar(&debug, "debug", false, "show debug output") rootCmd.PersistentFlags().BoolVar(&resetCache, "reset-cache", false, "set narinfo-cache-negative-ttl to 0") } diff --git a/pkgs/oizys/internal/oizys/main.go b/pkgs/oizys/internal/oizys/main.go index 3d26591..45cf0ad 100644 --- a/pkgs/oizys/internal/oizys/main.go +++ b/pkgs/oizys/internal/oizys/main.go @@ -30,6 +30,7 @@ type Oizys struct { verbose bool systemPath bool resetCache bool + debug bool } func New() *Oizys { @@ -69,6 +70,8 @@ func SetFlake(path string) { } } +func SetDebug(debug bool) { o.debug = debug } + func SetCache(name string) { if name != "" { o.cache = name @@ -215,10 +218,11 @@ func parseDryRun2(buf string) ([]string, []string) { return parts[0], parts[1] } +// TODO: refactor to account for --debug and not --verbose? func showDryRunResult(nixOutput string, verbose bool) { toBuild, toFetch := parseDryRun(nixOutput) - toBuild.show(verbose) - toFetch.show(verbose) + toFetch.show(o.debug) + toBuild.show(true) } func Dry(verbose bool, minimal bool, rest ...string) { @@ -288,7 +292,7 @@ func NixBuild(nom bool, minimal bool, rest ...string) { } cmd.Args = append(cmd.Args, append(drvs, "--no-link")...) } - if !o.inCI { + if !o.inCI { cmd.Args = append(cmd.Args, "--log-format", "multiline") } cmd.Args = append(cmd.Args, rest...)