A command line tool for interacting with Orbit on the Internet Computer.
(self)
| 101 | impl DfxOrbitArgs { |
| 102 | /// A command line tool for interacting with Orbit on the Internet Computer. |
| 103 | pub async fn execute(self) -> anyhow::Result<()> { |
| 104 | let logger = init_logger(self.verbose, self.quiet)?; |
| 105 | trace!(logger, "Calling tool with arguments:\n{:#?}", self); |
| 106 | |
| 107 | let orbit_agent = OrbitExtensionAgent::new()?; |
| 108 | |
| 109 | // We don't need to instanciate a StationAgent to execute this command directly on the orbit agent |
| 110 | if let DfxOrbitSubcommands::Station(station_args) = self.command { |
| 111 | station_args.execute(orbit_agent)?; |
| 112 | return Ok(()); |
| 113 | }; |
| 114 | |
| 115 | let config = if let Some(station_name) = self.station { |
| 116 | orbit_agent.station(&station_name)? |
| 117 | } else if let Some(station_file) = self.station_file { |
| 118 | orbit_agent.station_from_path(&station_file)? |
| 119 | } else { |
| 120 | orbit_agent |
| 121 | .default_station()? |
| 122 | .ok_or_else(|| anyhow::format_err!("No default station specified"))? |
| 123 | }; |
| 124 | |
| 125 | let dfx_orbit = DfxOrbit::new(orbit_agent, config, self.identity, logger).await?; |
| 126 | |
| 127 | match self.command { |
| 128 | // Nicer display, json optional |
| 129 | DfxOrbitSubcommands::Me(args) => { |
| 130 | let ans = dfx_orbit.station.me().await?; |
| 131 | if args.json { |
| 132 | println!("{}", serde_json::to_string_pretty(&ans)?); |
| 133 | } else { |
| 134 | println!("{}", dfx_orbit.display_me(ans)?); |
| 135 | } |
| 136 | Ok(()) |
| 137 | } |
| 138 | DfxOrbitSubcommands::Request(request_args) => { |
| 139 | let request = dfx_orbit |
| 140 | .station |
| 141 | .request(request_args.into_request(&dfx_orbit).await?) |
| 142 | .await?; |
| 143 | dfx_orbit.print_create_request_info(&request); |
| 144 | |
| 145 | Ok(()) |
| 146 | } |
| 147 | DfxOrbitSubcommands::Verify(verify_args) => { |
| 148 | let request = dfx_orbit |
| 149 | .station |
| 150 | .review_id(GetRequestInput { |
| 151 | request_id: verify_args.request_id.clone(), |
| 152 | with_full_info: Some(false), |
| 153 | }) |
| 154 | .await?; |
| 155 | |
| 156 | println!( |
| 157 | "{}", |
| 158 | dfx_orbit.display_get_request_response(request.clone())? |
| 159 | ); |
| 160 |
no test coverage detected