package main

import (
	"fmt"
	"os"
	"time"

	"github.com/spf13/cobra/doc"

	"mstore/cmd/mstorectl/util"
)

func run() error {
	var err error
	os.Args[0] = "mstorectl"
	util := util.NewUtil()
	err = util.Build()
	if err != nil {
		return err
	}

	cmd := util.GetRooCmd()
	now := time.Now()
	header := &doc.GenManHeader{
		Title:   "mstorectl",
		Section: "1",
		Manual:  "User commands",
		Source:  "mstorectl command",
		Date:    &now,
	}
	opts := doc.GenManTreeOptions{
		Header:           header,
		Path:             "./",
		CommandSeparator: "-",
	}
	err = doc.GenManTreeFromOpts(cmd, opts)
	if err != nil {
		return err
	}
	return err
}

func main() {
	err := run()
	if err != nil {
		fmt.Printf("err: %v\n", err)
	}

}
