Refactored main.go into cmd/jobsearch/main.go (in case separate commands are introduced later) which has required the options mechanism to change slightly as well as the logging.
This commit is contained in:
1 parent
de3ebf68c5
commit
6436253629
14 files changed
+273
-224
No files matched your search
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright © 2026 Craig Williams <craig@avsdev.uk>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package cli
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
|
||||
"git.avsdev.uk/Go/job-search/internal/log"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func SetupIntialLogging(cmd *cobra.Command) {
|
||||
// Start logging to terminal first - any commands that want to use file
|
||||
// logging should activate it themselves
|
||||
log.LogToTerminal()
|
||||
|
||||
// Check for quiet flag
|
||||
if quiet, _ := cmd.Flags().GetBool("quiet"); quiet {
|
||||
log.SetLevel(slog.LevelError)
|
||||
}
|
||||
|
||||
// Check for debug logging enabled (overrides quiet flag)
|
||||
debugEnabled, _ := cmd.Flags().GetBool("debug")
|
||||
if debugEnabled {
|
||||
log.EnableDebug()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user