mirror of
https://github.com/Dasharo/sbctl.git
synced 2026-03-06 15:04:14 -08:00
sbctl: Fix human readable output being printed when using --json
`PersistentPreRun` was being overwritten later in `main()`, causing `logging.PrintOff()` to never be called. Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
This commit is contained in:
@@ -64,15 +64,6 @@ func baseFlags(cmd *cobra.Command) {
|
||||
flags.BoolVar(&cmdOptions.DisableLandlock, "disable-landlock", false, "Disable landlock sandboxing")
|
||||
flags.BoolVar(&cmdOptions.Debug, "debug", false, "Enable verbose debug logging")
|
||||
flags.StringVarP(&cmdOptions.Config, "config", "", "", "Path to configuration file")
|
||||
|
||||
cmd.PersistentPreRun = func(cmd *cobra.Command, args []string) {
|
||||
if cmdOptions.JsonOutput {
|
||||
logging.PrintOff()
|
||||
}
|
||||
if cmdOptions.QuietOutput {
|
||||
logging.DisableInfo = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func JsonOut(v interface{}) error {
|
||||
@@ -134,6 +125,12 @@ func main() {
|
||||
|
||||
// We need to set this after we have parsed stuff
|
||||
rootCmd.PersistentPreRun = func(_ *cobra.Command, _ []string) {
|
||||
if cmdOptions.JsonOutput {
|
||||
logging.PrintOff()
|
||||
}
|
||||
if cmdOptions.QuietOutput {
|
||||
logging.DisableInfo = true
|
||||
}
|
||||
if cmdOptions.DisableLandlock {
|
||||
state.Config.Landlock = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user