add debug flag

This commit is contained in:
Daylin Morgan 2024-07-02 10:21:40 -05:00
parent 6930508add
commit a5d5d7d325
Signed by: daylin
GPG key ID: 950D13E9719334AD
2 changed files with 11 additions and 4 deletions

View file

@ -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")
}

View file

@ -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) {