Refactored a bit to put the configuration and logging setup before Cobra launches, so it doesn't need to be handled in every sub-command
This commit is contained in:
parent
4d77a0e2bc
commit
1ccd481f9e
11
adept.go
11
adept.go
@ -2,9 +2,20 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"git.metaunix.net/BitGoblin/adept/cmd"
|
"git.metaunix.net/BitGoblin/adept/cmd"
|
||||||
|
"git.metaunix.net/BitGoblin/adept/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
// start the app - that's where all the good stuff happens
|
// start the app - that's where all the good stuff happens
|
||||||
func main() {
|
func main() {
|
||||||
|
// load configuration via Viper
|
||||||
|
config.LoadConfig()
|
||||||
|
|
||||||
|
// configure our app logging
|
||||||
|
logHandle := config.InitLogging()
|
||||||
|
if logHandle != nil {
|
||||||
|
defer logHandle.Close()
|
||||||
|
}
|
||||||
|
|
||||||
|
// launch the Cobra CLI framework
|
||||||
cmd.Execute()
|
cmd.Execute()
|
||||||
}
|
}
|
||||||
|
10
cmd/root.go
10
cmd/root.go
@ -7,7 +7,6 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
"git.metaunix.net/BitGoblin/adept/config"
|
|
||||||
"git.metaunix.net/BitGoblin/adept/transcoder"
|
"git.metaunix.net/BitGoblin/adept/transcoder"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -18,15 +17,6 @@ var rootCmd = &cobra.Command{
|
|||||||
Long: `An automated video transcoder service that archives ingested footage.
|
Long: `An automated video transcoder service that archives ingested footage.
|
||||||
https://git.metaunix.net/BitGoblin/adept`,
|
https://git.metaunix.net/BitGoblin/adept`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
// load configuration via Viper
|
|
||||||
config.LoadConfig()
|
|
||||||
|
|
||||||
// configure our app logging
|
|
||||||
logHandle := config.InitLogging()
|
|
||||||
if logHandle != nil {
|
|
||||||
defer logHandle.Close()
|
|
||||||
}
|
|
||||||
|
|
||||||
// initialize the video repository
|
// initialize the video repository
|
||||||
r := transcoder.NewRepository(viper.GetString("transcoder.repository"))
|
r := transcoder.NewRepository(viper.GetString("transcoder.repository"))
|
||||||
|
|
||||||
|
12
cmd/setup.go
12
cmd/setup.go
@ -4,7 +4,6 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
"git.metaunix.net/BitGoblin/adept/config"
|
|
||||||
"git.metaunix.net/BitGoblin/adept/transcoder"
|
"git.metaunix.net/BitGoblin/adept/transcoder"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -16,17 +15,8 @@ func init() {
|
|||||||
var setupCmd = &cobra.Command{
|
var setupCmd = &cobra.Command{
|
||||||
Use: "setup",
|
Use: "setup",
|
||||||
Short: "Initialize the video directories.",
|
Short: "Initialize the video directories.",
|
||||||
Long: `Adept can't run if it doesn't have a place to ingest/transcode files from.`,
|
Long: `Adept can't run gif it doesn't have a place to ingest/transcode files from.`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
// load configuration via Viper
|
|
||||||
config.LoadConfig()
|
|
||||||
|
|
||||||
// configure our app logging
|
|
||||||
logHandle := config.InitLogging()
|
|
||||||
if logHandle != nil {
|
|
||||||
defer logHandle.Close()
|
|
||||||
}
|
|
||||||
|
|
||||||
// initialize the video repository
|
// initialize the video repository
|
||||||
r := transcoder.NewRepository(viper.GetString("transcoder.repository"))
|
r := transcoder.NewRepository(viper.GetString("transcoder.repository"))
|
||||||
r.Setup()
|
r.Setup()
|
||||||
|
Loading…
Reference in New Issue
Block a user