Files

44 lines
1009 B
Go

// Copyright (C) 2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package configcmd
import (
"errors"
"fmt"
"github.com/luxfi/cli/v2/pkg/constants"
"github.com/luxfi/cli/v2/pkg/ux"
"github.com/spf13/cobra"
)
func handleBooleanSetting(cmd *cobra.Command, key string, args []string) error {
if len(args) == 0 {
ux.Logger.PrintToUser(cmd.UsageString())
ux.Logger.PrintToUser("")
if app.Conf.GetConfigBoolValue(key) {
ux.Logger.PrintToUser("Current Setting: Enabled")
} else {
ux.Logger.PrintToUser("Current Setting: Disabled")
}
return nil
}
if len(args) != 1 {
return fmt.Errorf("unexpected number of arguments")
}
arg := args[0]
switch arg {
case constants.Enable:
if err := app.Conf.SetConfigValue(key, true); err != nil {
return err
}
case constants.Disable:
if err := app.Conf.SetConfigValue(key, false); err != nil {
return err
}
default:
return errors.New("Invalid argument '" + arg + "'")
}
return nil
}