(response: OwnerResponse, json: bool)
| 675 | } |
| 676 | |
| 677 | fn print_reservation(response: OwnerResponse, json: bool) -> CliResult<()> { |
| 678 | let (turn, committed) = match response { |
| 679 | OwnerResponse::ProvenanceTurn { turn, committed } => (turn, committed), |
| 680 | other => return Err(unexpected_response("reserve", other).into()), |
| 681 | }; |
| 682 | let output = ReserveOutput { |
| 683 | protocol_version: PROTOCOL_VERSION, |
| 684 | committed, |
| 685 | turn, |
| 686 | }; |
| 687 | if json { |
| 688 | println!( |
| 689 | "{}", |
| 690 | serde_json::to_string(&output).map_err(anyhow::Error::from)? |
| 691 | ); |
| 692 | } else { |
| 693 | println!( |
| 694 | "reserved provenance turn {} generation {} (committed)", |
| 695 | output.turn.provenance_id.get(), |
| 696 | output.turn.generation |
| 697 | ); |
| 698 | } |
| 699 | Ok(()) |
| 700 | } |
| 701 | |
| 702 | fn unexpected_response(operation: &str, response: OwnerResponse) -> anyhow::Error { |
| 703 | match response { |
no test coverage detected