Skip to content

Commit

Permalink
✨ Add proper initialization and logging configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
wesen committed Aug 6, 2023
1 parent c2f3144 commit 057192c
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions cmd/mastoid/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,42 @@ package main

import (
"fmt"
clay "github.com/go-go-golems/clay/pkg"
"github.com/go-go-golems/glazed/pkg/help"
cmds "github.com/go-go-golems/go-go-labs/cmd/mastoid/cmds"
"github.com/go-go-golems/go-go-labs/cmd/mastoid/pkg"
"github.com/spf13/cobra"
)

var rootCmd = &cobra.Command{
Use: "mastoid",
Short: "mastoid is a CLI app to interact with Mastodon",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
// reinitialize the logger because we can now parse --log-level and co
// from the command line flag
err := clay.InitLogger()
cobra.CheckErr(err)
},
}

func initRootCmd() (*help.HelpSystem, error) {
helpSystem := help.NewHelpSystem()
helpSystem.SetupCobraRootCommand(rootCmd)

err := clay.InitViper("mastoid", rootCmd)
if err != nil {
return nil, err
}
err = clay.InitLogger()
if err != nil {
return nil, err
}

return helpSystem, nil
}

func main() {
pkg.InitConfig()
_, err := initRootCmd()
cobra.CheckErr(err)

cmds.ThreadCmd.Flags().StringP("status-id", "s", "", "Status ID")
cmds.ThreadCmd.Flags().BoolP("verbose", "v", false, "Verbose output")
Expand Down

0 comments on commit 057192c

Please sign in to comment.