// SPDX-License-Identifier: GPL-3.0-or-later

// Package config provides default configuration values for the CLI.
package config

import "time"

// Default output settings
const (
	// DefaultOutputColor is the default color mode.
	DefaultOutputColor = "auto"

	// DefaultProgressStyle is the default progress bar style.
	DefaultProgressStyle = "bar"

	// DefaultDateFormat is the default date format (Go time format).
	DefaultDateFormat = "2006-01-02 15:04"

	// DefaultSizeUnits is the default size unit mode.
	DefaultSizeUnits = "auto"
)

// Default backend settings
const (
	// DefaultBackendURL is the default backend API URL.
	DefaultBackendURL = "http://localhost:62774"

	// DefaultTimeout is the default connection timeout.
	// Increased for Tor-based operations which have higher latency.
	DefaultTimeout = 120 * time.Second

	// DefaultAutoStartDaemon determines if daemon auto-starts.
	DefaultAutoStartDaemon = true
)

// Default backup settings
const (
	// DefaultExcludeCaches determines if CACHEDIR.TAG dirs are excluded.
	DefaultExcludeCaches = true

	// DefaultOneFileSystem determines if backup crosses filesystem boundaries.
	DefaultOneFileSystem = false
)

// Default retention/forget settings
const (
	// DefaultKeepLast is the default number of snapshots to keep.
	DefaultKeepLast = 5

	// DefaultKeepDaily is the default number of daily snapshots to keep.
	DefaultKeepDaily = 7

	// DefaultKeepWeekly is the default number of weekly snapshots to keep.
	DefaultKeepWeekly = 4

	// DefaultKeepMonthly is the default number of monthly snapshots to keep.
	DefaultKeepMonthly = 12

	// DefaultKeepYearly is the default number of yearly snapshots to keep.
	DefaultKeepYearly = 5
)

// DefaultShellAliases provides recommended shell aliases.
var DefaultShellAliases = map[string]string{
	"pb":   "privatebackup",
	"pbb":  "privatebackup backup",
	"pbr":  "privatebackup restore",
	"pbs":  "privatebackup snapshots",
	"pbst": "privatebackup status",
}

// NewDefaultConfig creates a new configuration with default values.
func NewDefaultConfig() *Config {
	return &Config{
		Output: OutputConfig{
			Color:         DefaultOutputColor,
			ProgressStyle: DefaultProgressStyle,
			DateFormat:    DefaultDateFormat,
			SizeUnits:     DefaultSizeUnits,
		},
		Backend: BackendConfig{
			URL:             DefaultBackendURL,
			Timeout:         DefaultTimeout,
			AutoStartDaemon: DefaultAutoStartDaemon,
		},
		Defaults: DefaultsConfig{
			Backup: BackupDefaults{
				ExcludeCaches: DefaultExcludeCaches,
				OneFileSystem: DefaultOneFileSystem,
			},
			Forget: ForgetDefaults{
				KeepLast:    DefaultKeepLast,
				KeepDaily:   DefaultKeepDaily,
				KeepWeekly:  DefaultKeepWeekly,
				KeepMonthly: DefaultKeepMonthly,
				KeepYearly:  DefaultKeepYearly,
			},
		},
		Shell: ShellConfig{
			Aliases: DefaultShellAliases,
		},
	}
}
