@@ -8,17 +8,27 @@ import (
88 "fmt"
99 "log"
1010
11+ "github.com/elastic/elastic-agent-changelog-tool/internal/assets"
1112 "github.com/elastic/elastic-agent-changelog-tool/internal/changelog"
1213 "github.com/spf13/afero"
1314 "github.com/spf13/cobra"
1415 "github.com/spf13/viper"
1516)
1617
18+ var RenderLongDescription = fmt .Sprintf (`Use this command to render the consolidated changelog.
19+
20+ --version is required. Consolidated changelog version (x.y.z) in 'changelogs' folder
21+ --template is optional. Specify full path to your template file or use predefined templates. Default: asciidoc-embedded
22+
23+ Predefined templates:
24+ %s
25+ ` , assets .GetEmbeddedTemplates ().String ())
26+
1727func RenderCmd (fs afero.Fs ) * cobra.Command {
1828 renderCmd := & cobra.Command {
1929 Use : "render" ,
2030 Short : "Render a changelog in an asciidoc file" ,
21- Long : "Render a changelog in an asciidoc file" ,
31+ Long : RenderLongDescription ,
2232 Args : func (cmd * cobra.Command , args []string ) error {
2333 return nil
2434 },
@@ -31,12 +41,17 @@ func RenderCmd(fs afero.Fs) *cobra.Command {
3141 return fmt .Errorf ("error parsing flag 'version': %w" , err )
3242 }
3343
44+ template , err := cmd .Flags ().GetString ("template" )
45+ if err != nil {
46+ return fmt .Errorf ("error parsing flag 'template': %w" , err )
47+ }
48+
3449 c , err := changelog .FromFile (fs , fmt .Sprintf ("./%s/%s.yaml" , dest , version ))
3550 if err != nil {
3651 return fmt .Errorf ("error loading changelog from file: %w" , err )
3752 }
3853
39- r := changelog .NewRenderer (fs , c , renderedDest )
54+ r := changelog .NewRenderer (fs , c , renderedDest , template )
4055
4156 if err := r .Render (); err != nil {
4257 return fmt .Errorf ("cannot build asciidoc file: %w" , err )
@@ -46,6 +61,7 @@ func RenderCmd(fs afero.Fs) *cobra.Command {
4661 },
4762 }
4863
64+ renderCmd .Flags ().String ("template" , viper .GetString ("template" ), "The template used to generate the changelog" )
4965 renderCmd .Flags ().String ("version" , "" , "The version of the consolidated changelog being created" )
5066 err := renderCmd .MarkFlagRequired ("version" )
5167 if err != nil {
0 commit comments