celestial_pointing/commands/
adjust.rs1use super::{Command, CommandOutput};
2use crate::error::{Error, Result};
3use crate::session::{AdjustDirection, Session};
4
5pub struct Adjust;
6
7impl Command for Adjust {
8 fn name(&self) -> &str {
9 "ADJUST"
10 }
11 fn description(&self) -> &str {
12 "Set model correction direction"
13 }
14
15 fn execute(&self, session: &mut Session, args: &[&str]) -> Result<CommandOutput> {
16 if args.is_empty() {
17 let current = match session.adjust_direction {
18 AdjustDirection::TelescopeToStar => "T (telescope to star)",
19 AdjustDirection::StarToTelescope => "S (star to telescope)",
20 };
21 return Ok(CommandOutput::Text(format!(
22 "Current direction: {}",
23 current
24 )));
25 }
26 match args[0].to_uppercase().as_str() {
27 "T" => {
28 session.adjust_direction = AdjustDirection::TelescopeToStar;
29 Ok(CommandOutput::Text(
30 "Direction: telescope to star".to_string(),
31 ))
32 }
33 "S" => {
34 session.adjust_direction = AdjustDirection::StarToTelescope;
35 Ok(CommandOutput::Text(
36 "Direction: star to telescope".to_string(),
37 ))
38 }
39 _ => Err(Error::Parse(format!(
40 "ADJUST requires T or S, got {}",
41 args[0]
42 ))),
43 }
44 }
45}