Log messages are lower-case event names with their details as key/value
attributes ("error" for errors), in place of formatted strings.
Loggable package take a WithLogger option as part of their "New*" call,
defaulting to slog.Default(). Each tags its lines with its `component`.
Some debug loggers print directly rather than using slog when in
terminal logging mode.
29 lines
746 B
Go
29 lines
746 B
Go
package config
|
|
|
|
import (
|
|
"log/slog"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"git.avsdev.uk/Go/job-search/internal/cli"
|
|
)
|
|
|
|
// NewCommand returns the "config" command, which shows and edits the configuration.
|
|
func NewCommand(opts *cli.Options) *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "config",
|
|
Short: "Configuration management",
|
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
|
slog.Debug("command persistent pre-run", "command", "config")
|
|
},
|
|
PersistentPostRun: func(cmd *cobra.Command, args []string) {
|
|
slog.Debug("command persistent post-run", "command", "config")
|
|
},
|
|
}
|
|
cmd.AddCommand(commandShow(opts))
|
|
cmd.AddCommand(commandGet(opts))
|
|
cmd.AddCommand(commandSet(opts))
|
|
cmd.AddCommand(commandInit())
|
|
return cmd
|
|
}
|