jcli vote-cast: add option for switching between public/private votes
@@ -18,6 +18,10 @@ pub struct VoteCastCmd {
/// the number of choice within the proposal you vote for
pub choice: u8,
+ /// should be used for vote plans with public votes
+ #[structopt(long = "public")]
+ pub public: bool,
+
/// write the output to the given file or print it to the standard output if not defined
#[structopt(long = "output")]
pub output: Option<PathBuf>,
@@ -25,13 +29,15 @@ pub struct VoteCastCmd {
impl VoteCastCmd {
pub fn exec(self) -> Result<(), Error> {
- let vote_cast = VoteCast::new(
- self.vote_plan_id,
- self.proposal_index,
+ let payload = if self.public {
Payload::Public {
choice: Choice::new(self.choice),
- },
- );
+ }
+ } else {
+ unimplemented!("private votes are not supported yet");
+ };
+
+ let vote_cast = VoteCast::new(self.vote_plan_id, self.proposal_index, payload);
let cert = Certificate::VoteCast(vote_cast);
write_cert(self.output.as_deref(), cert.into())
}
