Skip to content

Commit

Permalink
wwwcli: Add new help messages, fix filename
Browse files Browse the repository at this point in the history
This commit adds new help messages for the commands:
- commentslikes
- inventory
- proposalvotes
- tally
- vote
- votestatus

It also renames the file 'commentsvotes.go' to 'commentslikes.go'. This
fixes an oversight in a previous refactoring. I'm guessing from the
folowing commit: eae628c
  • Loading branch information
Seth Benton authored and lukebp committed Feb 1, 2019
1 parent 052a120 commit 3cbf2f1
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 16 deletions.
35 changes: 35 additions & 0 deletions politeiawww/cmd/politeiawwwcli/commands/commentslikes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package commands

// Help message displayed for the command 'politeiawwwcli help commentslikes'
var CommentsLikesCmdHelpMsg = `commentslikes "token"
Fetch all the comments voted on by the user for a given proposal.
Arguments:
1. token (string, required) Proposal censorship token
Result:
{
"commentslikes": [
{
"action": (string) Vote (upvote or downvote)
"commentid" (string) Id of the comment
"token": (string) Proposal censorship token
},
]
}`

type CommentsLikesCmd struct {
Args struct {
Token string `positional-arg-name:"token"`
} `positional-args:"true" required:"true"`
}

func (cmd *CommentsLikesCmd) Execute(args []string) error {
cvr, err := c.UserCommentsLikes(cmd.Args.Token)
if err != nil {
return err
}
return Print(cvr, cfg.Verbose, cfg.RawJSON)
}
15 changes: 0 additions & 15 deletions politeiawww/cmd/politeiawwwcli/commands/commentsvotes.go

This file was deleted.

10 changes: 10 additions & 0 deletions politeiawww/cmd/politeiawwwcli/commands/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ func (cmd *HelpCmd) Execute(args []string) error {
fmt.Printf("%s\n", VerifyUserPaymentCmdHelpMsg)
case "startvote":
fmt.Printf("%s\n", StartVoteCmdHelpMsg)
case "proposalvotes":
fmt.Printf("%s\n", ProposalVotesCmdHelpMsg)
case "votestatus":
fmt.Printf("%s\n", VoteStatusCmdHelpMsg)
case "inventory":
fmt.Printf("%s\n", InventoryCmdHelpMsg)
case "tally":
fmt.Printf("%s\n", TallyCmdHelpMsg)
case "commentslikes":
fmt.Printf("%s\n", CommentsLikesCmdHelpMsg)
default:
fmt.Printf("invalid command\n")
}
Expand Down
26 changes: 26 additions & 0 deletions politeiawww/cmd/politeiawwwcli/commands/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,32 @@ import (
"github.com/decred/dcrwallet/rpc/walletrpc"
)

// Help message displayed for the command 'politeiawwwcli help inventory'
var InventoryCmdHelpMsg = `inventory
Fetch the proposals that are being voted on.
Arguments:
None
Response:
Token: (string) Proposal censorship token
Proposal : (string) Proposal name
Eligible tickets: (int) Number of eligible tickets
Start block : (string) Block height at start of vote
End block : (string) Block height at end of vote
Mask : (uint64) Valid votebits
Vote Option:
ID : (string) Unique word identifying vote (e.g. 'no')
Description : (string) Longer description of the vote
Bits : (uint64) Bits used for this option (e.g. '1')
Vote Option:
ID : (string) Unique word identifying vote (e.g. 'yes')
Description : (string) Longer description of the vote
Bits : (uint64) Bits used for this option (e.g. '2')
To choose this option: politeiawwwcli vote 'Token' 'ID'`

type InventoryCmd struct{}

func (cmd *InventoryCmd) Execute(args []string) error {
Expand Down
44 changes: 44 additions & 0 deletions politeiawww/cmd/politeiawwwcli/commands/proposalvotes.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,49 @@
package commands

// Help message displayed for the command 'politeiawwwcli help proposalvotes'
var ProposalVotesCmdHelpMsg = `proposalvotes "token"
Fetch vote results for a proposal.
Arguments:
1. token (string, required) Proposal censorship token
Request:
{
"token": (string) Proposal censorship token
}
Response:
{
"startvote": {
"publickey" (string) Public key of user that submitted proposal
"vote": {
"token": (string) Censorship token
"mask" (uint64) Valid votebits
"duration": (uint32) Duration of vote in blocks
"quorumpercentage" (uint32) Percent of votes required for quorum
"passpercentage": (uint32) Percent of votes required to pass
"options": [
{
"id" (string) Unique word identifying vote (e.g. yes)
"description" (string) Longer description of the vote
"bits": (uint64) Bits used for this option
},
]
},
"signature" (string) Signature of Votehash
},
"castvotes": [],
"startvotereply": {
"startblockheight": (string) Block height at start of vote
"startblockhash": (string) Hash of first block of vote interval
"endheight": (string) Block height at end of vote
"eligibletickets": [
"removed by politeiawwwcli for readability"
]
}
}`

type ProposalVotesCmd struct {
Args struct {
Token string `positional-arg-name:"token" description:"Proposal censorship token"`
Expand Down
23 changes: 23 additions & 0 deletions politeiawww/cmd/politeiawwwcli/commands/tally.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,29 @@ import (
"strconv"
)

// Help message displayed for the command 'politeiawwwcli help tally'
var TallyCmdHelpMsg = `tally "token"
Fetch the vote tally for a proposal.
Arguments:
1. token (string, required) Proposal censorship token
Response:
Vote Option:
ID : (string) Unique word identifying vote (e.g. 'no')
Description : (string) Longer description of the vote
Bits : (uint64) Bits used for this option (e.g. '1')
Votes received : (uint) Number of votes received
Percentage : (float64) Percentage of votes for vote option
Vote Option:
ID : (string) Unique word identifying vote (e.g. 'yes')
Description : (string) Longer description of the vote
Bits : (uint64) Bits used for this option (e.g. '2')
Votes received : (uint) Number of votes received
Percentage : (float64) Percentage of votes for vote option`

type TallyCmd struct {
Args struct {
Token string `positional-arg-name:"token" description:"Proposal censorship token"`
Expand Down
4 changes: 3 additions & 1 deletion politeiawww/cmd/politeiawwwcli/commands/vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ Arguments:
2. voteid (string, optional) A single word identifying vote (e.g. yes)
Result:
ActiveVotes: 500,`
Enter the private passphrase of your wallet:
Votes succeeded: (int) Number of successful votes
Votes failed : (int) Number of failed votes`

type VoteCmd struct {
Args struct {
Expand Down
43 changes: 43 additions & 0 deletions politeiawww/cmd/politeiawwwcli/commands/votestatus.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,48 @@
package commands

// Help message displayed for the command 'politeiawwwcli help votestatus'
var VoteStatusCmdHelpMsg = `votestatus "token"
Fetch vote status for a proposal.
Proposal vote status codes:
'0' - Invalid vote status
'1' - Vote has not been authorized by proposal author
'2' - Vote has been authorized by proposal author
'3' - Proposal vote has been started
'4' - Proposal vote has been finished
'5' - Proposal doesn't exist
Arguments:
1. token (string, required) Proposal censorship token
Request:
{
"token": (string) Proposal censorship token
}
Response:
{
"token": (string) Public key of user that submitted proposal
"status": (int) Vote status code
"totalvotes": (uint64) Total number of votes on proposal
"optionsresult": [
{
"option": {
"id": (string) Unique word identifying vote (e.g. 'yes')
"description": (string) Longer description of the vote
"bits": (uint64) Bits used for this option
},
"votesreceived": (uint64) Number of votes received
},
],
"endheight": (string) String encoded final block height of the vote
"numofeligiblevotes": (int) Total number of eligible votes
"quorumpercentage": (uint32) Percent of eligible votes required for quorum
"passpercentage": (uint32) Percent of total votes required to pass
}`

type VoteStatusCmd struct {
Args struct {
Token string `positional-arg-name:"token" description:"Proposal censorship token"`
Expand Down

0 comments on commit 3cbf2f1

Please sign in to comment.