Skip to content

Commit

Permalink
Add filter new proposals
Browse files Browse the repository at this point in the history
  • Loading branch information
fbsobreira committed Aug 12, 2020
1 parent 836ab2e commit d50fa83
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cmd/subcommands/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import (
"github.com/spf13/cobra"
)

var (
newOnlyProposals = false
)

func proposalSub() []*cobra.Command {
cmdProposalList := &cobra.Command{
Use: "list",
Expand Down Expand Up @@ -42,6 +46,9 @@ func proposalSub() []*cobra.Command {
expiration := time.Unix(proposal.ExpirationTime/1000, 0)
if expiration.Before(time.Now()) {
expired = true
if newOnlyProposals && expired {
continue
}
}

data := map[string]interface{}{
Expand All @@ -58,16 +65,16 @@ func proposalSub() []*cobra.Command {
result["totalCount"] = len(list.Proposals)
result["filterCount"] = len(pList)
result["proposals"] = pList
fmt.Println(result)
asJSON, _ := json.Marshal(result)
fmt.Println(common.JSONPrettyFormat(string(asJSON)))
return nil
},
}
cmdProposalList.Flags().BoolVar(&newOnlyProposals, "new", false, "Show only new proposals")

cmdProposalApprove := &cobra.Command{
Use: "approve",
Short: "List network proposals",
Short: "Approve network proposal",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
if signerAddress.String() == "" {
Expand Down

0 comments on commit d50fa83

Please sign in to comment.