2022-09-20 21:49:37 +00:00
|
|
|
/*
|
|
|
|
Copyright © 2022 Matthieu Derasse <git@derasse.fr>
|
|
|
|
|
|
|
|
*/
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"git.home.m-and-m.ovh/mderasse/gouick/helpers/api_types"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
|
|
|
// readmeCmd represents the readme command.
|
|
|
|
var readmeCmd = &cobra.Command{
|
|
|
|
Use: "readme",
|
|
|
|
Short: "Generate Readme",
|
2022-11-11 17:52:44 +00:00
|
|
|
Run: runGenerateReadme,
|
2022-09-20 21:49:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
generateCmd.AddCommand(readmeCmd)
|
|
|
|
}
|
|
|
|
|
|
|
|
// runGenerateReadmeAction will generate the Readme for the current project.
|
2022-11-11 17:52:44 +00:00
|
|
|
func runGenerateReadme(cmd *cobra.Command, args []string) {
|
2022-09-20 21:49:37 +00:00
|
|
|
log.Debugf("Starting command GenerateReadme")
|
|
|
|
currentPath, config, err := loadProjectAndConfig()
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
apiType, err := api_types.GetAPIType(config.ProjectType)
|
|
|
|
if err != nil {
|
|
|
|
log.Error("Impossible to load that API Type generator")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Generate ReadMe
|
|
|
|
log.Info("Generating ReadMe")
|
|
|
|
err = apiType.GenerateReadme(currentPath, config)
|
|
|
|
if err != nil {
|
|
|
|
log.Errorf("Fail to generate ReadMe. The following error happen: %s", err.Error())
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|