From 0fd8553bada4db3e268073e13804234a44808016 Mon Sep 17 00:00:00 2001 From: mslacken Date: Fri, 29 Apr 2022 10:07:15 +0200 Subject: [PATCH] add full output siwtch to wwctl version --- internal/app/wwctl/version/main.go | 34 ++++++++++++++++-------------- internal/app/wwctl/version/root.go | 2 ++ 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/internal/app/wwctl/version/main.go b/internal/app/wwctl/version/main.go index 6cee1028..3577036b 100644 --- a/internal/app/wwctl/version/main.go +++ b/internal/app/wwctl/version/main.go @@ -9,21 +9,23 @@ import ( ) func CobraRunE(cmd *cobra.Command, args []string) error { - - fmt.Printf("%-20s %-18s\n", "VERSION:", version.GetVersion()) - fmt.Printf("%-20s %-18s\n", "BINDIR:", buildconfig.BINDIR()) - fmt.Printf("%-20s %-18s\n", "DATADIR:", buildconfig.DATADIR()) - fmt.Printf("%-20s %-18s\n", "SYSCONFDIR:", buildconfig.SYSCONFDIR()) - fmt.Printf("%-20s %-18s\n", "LOCALSTATEDIR:", buildconfig.LOCALSTATEDIR()) - fmt.Printf("%-20s %-18s\n", "SRVDIR:", buildconfig.SRVDIR()) - fmt.Printf("%-20s %-18s\n", "TFTPDIR:", buildconfig.TFTPDIR()) - fmt.Printf("%-20s %-18s\n", "SYSTEMDDIR:", buildconfig.SYSTEMDDIR()) - fmt.Printf("%-20s %-18s\n", "WWOVERLAYDIR:", buildconfig.WWOVERLAYDIR()) - fmt.Printf("%-20s %-18s\n", "WWCHROOTDIR:", buildconfig.WWCHROOTDIR()) - fmt.Printf("%-20s %-18s\n", "WWPROVISIONDIR:", buildconfig.WWPROVISIONDIR()) - fmt.Printf("%-20s %-18s\n", "BASEVERSION:", buildconfig.VERSION()) - fmt.Printf("%-20s %-18s\n", "RELEASE:", buildconfig.RELEASE()) - fmt.Printf("%-20s %-18s\n", "WWCLIENTDIR:", buildconfig.WWCLIENTDIR()) - + if ListFull { + fmt.Printf("%-20s %-18s\n", "VERSION:", version.GetVersion()) + fmt.Printf("%-20s %-18s\n", "BINDIR:", buildconfig.BINDIR()) + fmt.Printf("%-20s %-18s\n", "DATADIR:", buildconfig.DATADIR()) + fmt.Printf("%-20s %-18s\n", "SYSCONFDIR:", buildconfig.SYSCONFDIR()) + fmt.Printf("%-20s %-18s\n", "LOCALSTATEDIR:", buildconfig.LOCALSTATEDIR()) + fmt.Printf("%-20s %-18s\n", "SRVDIR:", buildconfig.SRVDIR()) + fmt.Printf("%-20s %-18s\n", "TFTPDIR:", buildconfig.TFTPDIR()) + fmt.Printf("%-20s %-18s\n", "SYSTEMDDIR:", buildconfig.SYSTEMDDIR()) + fmt.Printf("%-20s %-18s\n", "WWOVERLAYDIR:", buildconfig.WWOVERLAYDIR()) + fmt.Printf("%-20s %-18s\n", "WWCHROOTDIR:", buildconfig.WWCHROOTDIR()) + fmt.Printf("%-20s %-18s\n", "WWPROVISIONDIR:", buildconfig.WWPROVISIONDIR()) + fmt.Printf("%-20s %-18s\n", "BASEVERSION:", buildconfig.VERSION()) + fmt.Printf("%-20s %-18s\n", "RELEASE:", buildconfig.RELEASE()) + fmt.Printf("%-20s %-18s\n", "WWCLIENTDIR:", buildconfig.WWCLIENTDIR()) + } else { + fmt.Println(version.GetVersion()) + } return nil } diff --git a/internal/app/wwctl/version/root.go b/internal/app/wwctl/version/root.go index 766d3b8f..4e88e9d9 100644 --- a/internal/app/wwctl/version/root.go +++ b/internal/app/wwctl/version/root.go @@ -11,9 +11,11 @@ var ( Args: cobra.ExactArgs(0), Aliases: []string{"vers"}, } + ListFull bool ) func init() { + baseCmd.PersistentFlags().BoolVarP(&ListFull, "full", "f", false, "List all compiled in variables.") } // GetRootCommand returns the root cobra.Command for the application.