Initial commit
This commit is contained in:
commit
02947128bc
24 changed files with 1126 additions and 0 deletions
51
cmd.go
Normal file
51
cmd.go
Normal file
|
@ -0,0 +1,51 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// rootCmd
|
||||
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file (default is $HOME/.bottin.presences.yaml)")
|
||||
|
||||
if err := BindFlags(rootCmd.PersistentFlags()); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// rootCmd represents the base command when called without any subcommands
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "presences",
|
||||
//Args: cobra.(0),
|
||||
Short: "Gestion de présences en Assemblée Générale",
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
log.Println("Starting bottin/presences microservice")
|
||||
|
||||
ctx := context.TODO()
|
||||
|
||||
cfg, err := ParseConfig()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if len(args) > 0 {
|
||||
if args[0] == "debugConfig" {
|
||||
log.Println("debug: Printing current config")
|
||||
cfgAsBytes, err := json.MarshalIndent(cfg, "", " ")
|
||||
if err != nil {
|
||||
log.Fatal("Cannot marshal config for printing:", err)
|
||||
}
|
||||
fmt.Println(string(cfgAsBytes))
|
||||
}
|
||||
}
|
||||
|
||||
if err := run(ctx, cfg); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
},
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue