diff --git a/internal/engine/command/crowdfund/create.go b/internal/engine/command/crowdfund/create.go index b72f84b..de44af9 100644 --- a/internal/engine/command/crowdfund/create.go +++ b/internal/engine/command/crowdfund/create.go @@ -41,5 +41,5 @@ func (c *CrowdfundCmd) createHandler( return cmd.RenderErrorTemplate(err) } - return cmd.RenderResultTemplate(".", campaign) + return cmd.RenderResultTemplate("campaign", campaign) } diff --git a/internal/engine/command/crowdfund/crowdfund.gen.go b/internal/engine/command/crowdfund/crowdfund.gen.go index fd23312..0d2e9ec 100644 --- a/internal/engine/command/crowdfund/crowdfund.gen.go +++ b/internal/engine/command/crowdfund/crowdfund.gen.go @@ -26,7 +26,7 @@ func (c *CrowdfundCmd) crowdfundCommand() *command.Command { Name: "create", Help: "Create a new crowdfunding campaign", Handler: c.createHandler, - ResultTemplate: `Crowdfund campaign '{{.Name}}' created successfully with {{ len(.Packages) }} packages`, + ResultTemplate: `Crowdfund campaign '{{.campaign.Title}}' created successfully with {{ .campaign.Packages | len }} packages`, AppIDs: entity.AllAppIDs(), TargetFlag: command.TargetMaskAll, Args: []command.Args{ @@ -70,7 +70,13 @@ func (c *CrowdfundCmd) crowdfundCommand() *command.Command { Name: "info", Help: "Get detailed information about a crowdfunding campaign", Handler: c.infoHandler, - ResultTemplate: ``, + ResultTemplate: `**{{.campaign.Title}}** +{{.campaign.Desc}} + +Packages: +{{range .campaign.Packages}} +- {{.Name}} +{{- end}}`, AppIDs: entity.AllAppIDs(), TargetFlag: command.TargetMaskAll, } diff --git a/internal/engine/command/crowdfund/crowdfund.yml b/internal/engine/command/crowdfund/crowdfund.yml index 1bab916..5ff6930 100644 --- a/internal/engine/command/crowdfund/crowdfund.yml +++ b/internal/engine/command/crowdfund/crowdfund.yml @@ -5,7 +5,7 @@ sub_commands: - name: create help: Create a new crowdfunding campaign result_template: | - Crowdfund campaign '{{.Name}}' created successfully with {{ len(.Packages) }} packages + Crowdfund campaign '{{.campaign.Title}}' created successfully with {{ .campaign.Packages | len }} packages args: - name: title desc: The title of this crowdfunding campaign @@ -25,6 +25,14 @@ sub_commands: help: View reports of a crowdfunding campaign - name: info help: Get detailed information about a crowdfunding campaign + result_template: | + **{{.campaign.Title}}** + {{.campaign.Desc}} + + Packages: + {{range .campaign.Packages}} + - {{.Name}} + {{- end}} - name: purchase help: Make a purchase in a crowdfunding campaign args: diff --git a/internal/engine/command/crowdfund/info.go b/internal/engine/command/crowdfund/info.go index 739dca4..d5a9187 100644 --- a/internal/engine/command/crowdfund/info.go +++ b/internal/engine/command/crowdfund/info.go @@ -5,17 +5,6 @@ import ( "github.com/pagu-project/pagu/internal/entity" ) -// Add caller.Name here? -const infoResponseTemplate = ` -**{{.campaign.Title}}** - -{{.campaign.Desc}} - -Packages: -{{range .campaign.Packages}} -- {{.Name}}{{end}} -` - func (c *CrowdfundCmd) infoHandler( _ *entity.User, cmd *command.Command,