1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
use super::*;

#[derive(Debug, Parser)]
pub(crate) struct Traits {
  #[clap(help = "Show traits for <SAT>.")]
  sat: Sat,
}

impl Traits {
  pub(crate) fn run(self) -> Result {
    print!("{}", self);
    Ok(())
  }
}

impl Display for Traits {
  fn fmt(&self, f: &mut Formatter) -> fmt::Result {
    writeln!(f, "number: {}", self.sat.n())?;
    writeln!(f, "decimal: {}", self.sat.decimal())?;
    writeln!(f, "degree: {}", self.sat.degree())?;
    writeln!(f, "name: {}", self.sat.name())?;
    writeln!(f, "height: {}", self.sat.height())?;
    writeln!(f, "cycle: {}", self.sat.cycle())?;
    writeln!(f, "epoch: {}", self.sat.epoch())?;
    writeln!(f, "period: {}", self.sat.period())?;
    writeln!(f, "offset: {}", self.sat.third())?;
    writeln!(f, "rarity: {}", self.sat.rarity())?;
    Ok(())
  }
}

#[cfg(test)]
mod tests {
  use super::*;

  #[test]
  fn first() {
    assert_eq!(
      Traits { sat: Sat(0) }.to_string(),
      "\
number: 0
decimal: 0.0
degree: 0°0′0″0‴
name: nvtdijuwxlp
height: 0
cycle: 0
epoch: 0
period: 0
offset: 0
rarity: mythic
",
    );
  }

  #[test]
  fn last() {
    assert_eq!(
      Traits {
        sat: Sat(2099999997689999)
      }
      .to_string(),
      "\
number: 2099999997689999
decimal: 6929999.0
degree: 5°209999′1007″0‴
name: a
height: 6929999
cycle: 5
epoch: 32
period: 3437
offset: 0
rarity: uncommon
",
    );
  }
}