func getLogger(config commands.RootConfig) log.Logger {
	if config.NoLog {
		return log.Noop
	}
	logrusLog := logrus.New()
	logrusLog.Out = config.Stderr  
	logrusLogEntry := logrus.NewEntry(logrusLog)
	if config.Debug {
		logrusLogEntry.Logger.SetLevel(logrus.DebugLevel)
	}
	switch config.LoggerType {
	case commands.LoggerTypeDefault:
		logrusLogEntry.Logger.SetFormatter(&logrus.TextFormatter{
			ForceColors:   !config.NoColor,
			DisableColors: config.NoColor,
		})
	case commands.LoggerTypeJSON:
		logrusLogEntry.Logger.SetFormatter(&logrus.JSONFormatter{})
	}
	logger := loglogrus.NewLogrus(logrusLogEntry).WithValues(log.Kv{
		"version": Version,
	})
	logger.Debugf("Debug level is enabled")  
	return logger
}
getLogger returns the application logger.
package main
import (
	"context"
	"fmt"
	"io"
	"os"
	"github.com/sirupsen/logrus"
	"gopkg.in/alecthomas/kingpin.v2"
	"github.com/slok/agebox/cmd/agebox/commands"
	"github.com/slok/agebox/internal/log"
	loglogrus "github.com/slok/agebox/internal/log/logrus"
)
var Version = "dev"
func Run(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) error {
	app := kingpin.New("agebox", "Age based repo file encrypt helper.")
	app.Version(Version)
	app.DefaultEnvars()
	config := commands.NewRootConfig(app)
	initCmd := commands.NewInitCommand(app)
	encryptCmd := commands.NewEncryptCommand(app)
	decryptCmd := commands.NewDecryptCommand(app)
	reencryptCmd := commands.NewReencryptCommand(app)
	untrackCmd := commands.NewUntrackCommand(app)
	catCmd := commands.NewCatCommand(app)
	validateCmd := commands.NewValidateCommand(app)
	cmds := map[string]commands.Command{
		initCmd.Name():      initCmd,
		encryptCmd.Name():   encryptCmd,
		decryptCmd.Name():   decryptCmd,
		reencryptCmd.Name(): reencryptCmd,
		untrackCmd.Name():   untrackCmd,
		catCmd.Name():       catCmd,
		validateCmd.Name():  validateCmd,
	}
	cmdName, err := app.Parse(args[1:])
	if err != nil {
		return fmt.Errorf("invalid command configuration: %w", err)
	}
	config.Stdin = stdin
	config.Stdout = stdout
	config.Stderr = stderr
	config.Logger = getLogger(*config)
	err = cmds[cmdName].Run(ctx, *config)
	if err != nil {
		return fmt.Errorf("%q command failed: %w", cmdName, err)
	}
	return nil
}