Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/cosmos/cosmos-sdk into likh…
Browse files Browse the repository at this point in the history
…ita/pool
  • Loading branch information
likhita-809 committed Sep 25, 2023
2 parents b49f1f5 + 2a29c7e commit 095ee20
Showing 1 changed file with 22 additions and 25 deletions.
47 changes: 22 additions & 25 deletions x/gov/client/cli/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,40 +199,37 @@ func getProposalSuggestions() []string {

// PromptMetadata prompts for proposal metadata or only title and summary if skip is true
func PromptMetadata(skip bool) (types.ProposalMetadata, error) {
var (
metadata types.ProposalMetadata
err error
)

if !skip {
metadata, err = Prompt(types.ProposalMetadata{}, "proposal")
metadata, err := Prompt(types.ProposalMetadata{}, "proposal")
if err != nil {
return metadata, fmt.Errorf("failed to set proposal metadata: %w", err)
}
} else {
// prompt for title and summary
titlePrompt := promptui.Prompt{
Label: "Enter proposal title",
Validate: client.ValidatePromptNotEmpty,
}

metadata.Title, err = titlePrompt.Run()
if err != nil {
return metadata, fmt.Errorf("failed to set proposal title: %w", err)
}
return metadata, nil
}

summaryPrompt := promptui.Prompt{
Label: "Enter proposal summary",
Validate: client.ValidatePromptNotEmpty,
}
// prompt for title and summary
titlePrompt := promptui.Prompt{
Label: "Enter proposal title",
Validate: client.ValidatePromptNotEmpty,
}

metadata.Summary, err = summaryPrompt.Run()
if err != nil {
return metadata, fmt.Errorf("failed to set proposal summary: %w", err)
}
title, err := titlePrompt.Run()
if err != nil {
return types.ProposalMetadata{}, fmt.Errorf("failed to set proposal title: %w", err)
}

summaryPrompt := promptui.Prompt{
Label: "Enter proposal summary",
Validate: client.ValidatePromptNotEmpty,
}

summary, err := summaryPrompt.Run()
if err != nil {
return types.ProposalMetadata{}, fmt.Errorf("failed to set proposal summary: %w", err)
}

return metadata, nil
return types.ProposalMetadata{Title: title, Summary: summary}, nil
}

// NewCmdDraftProposal let a user generate a draft proposal.
Expand Down

0 comments on commit 095ee20

Please sign in to comment.