use std::cli; use std::text; use vendor::replica_promote::replica_promote; fn main() { let arguments = cli_args(); if args_len(arguments) > 0 { if args_len(arguments) % 2 != 0 { stderr_line("Expected event and value pairs"); process_exit(2); } let mut live = replica_promote_start(); let mut i = 0; while i < args_len(arguments) { let input = args_at(arguments, i + 1); if !text_is_number(input) { stderr_line("Expected a whole numeric event value"); process_exit(2); } live = replica_promote_step(live, args_at(arguments, i), text_number(input)); let command = replica_promote_command(live); println!(command); if command == "reject" { process_exit(1); } i += 2; } return; } let mut state = replica_promote_start(); state = replica_promote_step(state, "target", 100.0); println!(replica_promote_command(state)); state = replica_promote_step(state, "lag", 80.0); println!(replica_promote_command(state)); state = replica_promote_step(state, "replayed", 101.0); println!(replica_promote_command(state)); state = replica_promote_step(state, "confirmed", 100.0); println!(replica_promote_command(state)); state = replica_promote_step(state, "confirmed", 101.0); println!(replica_promote_command(state)); state = replica_promote_step(state, "advertise", 101.0); println!(replica_promote_command(state)); }