celestial_pointing/commands/
help.rs1use super::{Command, CommandOutput};
2use crate::error::Result;
3use crate::session::Session;
4
5pub struct Help;
6
7impl Command for Help {
8 fn name(&self) -> &str {
9 "HELP"
10 }
11 fn description(&self) -> &str {
12 "Show available commands"
13 }
14
15 fn execute(&self, _session: &mut Session, args: &[&str]) -> Result<CommandOutput> {
16 if let Some(cmd) = args.first() {
17 Ok(CommandOutput::Text(command_help(cmd)))
18 } else {
19 Ok(CommandOutput::Text(general_help()))
20 }
21 }
22}
23
24fn command_help(cmd: &str) -> String {
25 match cmd.to_uppercase().as_str() {
26 "APPLY" => "APPLY <ra> <dec>\n Compute commanded encoder position for a target\n Args: h m s d m s OR decimal_hours decimal_degrees".into(),
27 "INDAT" => "INDAT <file>\n Load observations from file".into(),
28 "INMOD" => "INMOD <file>\n Load model from file".into(),
29 "OUTMOD" => "OUTMOD <file>\n Save model to file".into(),
30 "USE" => "USE <term> [term...]\n Add terms to model\n Example: USE IH ID CH NP MA ME".into(),
31 "LOSE" => "LOSE <term> [term...] | LOSE ALL\n Remove terms from model".into(),
32 "FIT" => "FIT\n Fit model to observations".into(),
33 "CLIST" => "CLIST\n List coefficients with uncertainties".into(),
34 "RESET" => "RESET\n Zero all coefficients".into(),
35 "SLIST" => "SLIST\n List observations with residuals".into(),
36 "MASK" => "MASK <obs> [obs...] | MASK <n>-<m>\n Exclude observations from fit".into(),
37 "UNMASK" => "UNMASK <obs> [obs...] | UNMASK ALL\n Include masked observations".into(),
38 "MVET" => "MVET <sigma> [R]\n Find weak terms (R to remove)".into(),
39 "OUTL" => "OUTL <sigma> [M]\n Find outliers (M to mask)".into(),
40 "FIX" => "FIX <term> [term...] | FIX ALL\n Fix terms at current values during fit".into(),
41 "UNFIX" => "UNFIX <term> [term...] | UNFIX ALL\n Allow fixed terms to be fitted".into(),
42 "PARALLEL" => "PARALLEL <term> [term...] | PARALLEL ALL\n Apply terms in parallel (default)".into(),
43 "CHAIN" => "CHAIN <term> [term...] | CHAIN ALL\n Apply terms sequentially (rigorous)".into(),
44 "ADJUST" => "ADJUST T|S\n T = telescope to star (default)\n S = star to telescope".into(),
45 "FAUTO" => "FAUTO <order> [H|D]\n Add harmonics up to Nth order\n H = HA only, D = Dec only".into(),
46 "OPTIMAL" => "OPTIMAL [max_terms] [bic_threshold]\n Auto-build optimal model using BIC selection\n Defaults: max 30 terms, threshold -6.0".into(),
47 "LST" => "LST [h m s | decimal_hours | CLEAR]\n Show/set local sidereal time".into(),
48 "CORRECT" => "CORRECT <ra> <dec>\n Compute actual sky position from encoder reading\n Args: h m s d m s OR decimal_hours decimal_degrees".into(),
49 "PREDICT" => "PREDICT <ra> <dec>\n Show per-term correction breakdown\n Args: h m s d m s OR decimal_hours decimal_degrees".into(),
50 "GSCAT" => "GSCAT [file.svg]\n Scatter plot of residuals (dX vs dDec)\n No args = terminal, with file = SVG output".into(),
51 "GDIST" => "GDIST [file.svg] [D]\n Histogram of residual distribution\n No args = terminal (both dX and dDec)\n D = declination residuals (default = dX)".into(),
52 "GMAP" => "GMAP [file.svg] [scale]\n Sky map with residual vectors\n No args = terminal, scale = arrow scale factor (default 10)".into(),
53 "GHA" => "GHA [file.svg]\n Residuals vs hour angle\n No args = terminal, with file = two SVGs (_dx, _dd)".into(),
54 "GDEC" => "GDEC [file.svg]\n Residuals vs declination\n No args = terminal, with file = two SVGs (_dx, _dd)".into(),
55 "GHYST" => "GHYST [file.svg]\n Hysteresis plot (residuals by sequence and pier side)\n No args = terminal, with file = two SVGs (_east, _west)".into(),
56 "SHOW" => "SHOW\n Display session state".into(),
57 "HELP" => "HELP [command]\n Show help for a command".into(),
58 "QUIT" => "QUIT\n Exit the program".into(),
59 _ => format!("Unknown command: {}", cmd),
60 }
61}
62
63fn general_help() -> String {
64 "\
65Commands:
66 APPLY <ra> <dec> Compute commanded position for target
67 INDAT <file> Load observations
68 INMOD <file> Load model
69 OUTMOD <file> Save model
70
71 USE <terms> Add terms to model
72 LOSE <terms> Remove terms (or ALL)
73 FIT Fit model
74 CLIST List coefficients
75 RESET Zero all coefficients
76
77 SLIST List observations
78 MASK <obs> Exclude observations
79 UNMASK <obs> Include observations
80 MVET <sigma> Find/remove weak terms
81 OUTL <sigma> Find/mask outliers
82
83 FIX <terms> Fix terms during fit
84 UNFIX <terms> Unfix terms
85 PARALLEL <terms> Apply terms in parallel
86 CHAIN <terms> Apply terms sequentially
87 ADJUST T|S Set model direction
88
89 FAUTO <n> Add harmonics to nth order
90 OPTIMAL Auto-build optimal model
91 LST [time|CLEAR] Set/show local sidereal time
92
93 CORRECT <ra> <dec> Actual sky position from encoders
94 PREDICT <ra> <dec> Per-term correction breakdown
95
96 GSCAT [file] Scatter plot of residuals
97 GDIST [file] Histogram of residuals
98 GMAP [file] Sky map with residual vectors
99 GHA [file] Residuals vs hour angle
100 GDEC [file] Residuals vs declination
101 GHYST [file] Hysteresis plot
102
103 SHOW Display session state
104 HELP [cmd] Show help
105 QUIT Exit
106
107Type HELP <command> for details."
108 .to_string()
109}