1use std::collections::HashSet;
6#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
7pub enum OutputComponent {
18#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
25 pub fn components(self, interactive_terminal: bool) -> &'static [OutputComponent] {
27 OutputComponent::Auto => {
28 if interactive_terminal {
29 OutputComponent::Full.components(interactive_terminal)
31 OutputComponent::Plain.components(interactive_terminal)
34 OutputComponent::Changes => &[OutputComponent::Changes],
35 OutputComponent::Grid => &[OutputComponent::Grid],
36 OutputComponent::Header => &[OutputComponent::Header],
37 OutputComponent::Numbers => &[OutputComponent::Numbers],
38 OutputComponent::Snip => &[OutputComponent::Snip],
39 OutputComponent::Full => &[
40 OutputComponent::Changes,
41 OutputComponent::Grid,
42 OutputComponent::Header,
43 OutputComponent::Numbers,
44 OutputComponent::Snip,
46 OutputComponent::Plain => &[],
51impl FromStr for OutputComponent {
54 fn from_str(s: &str) -> Result<Self> {
56 "auto" => Ok(OutputComponent::Auto),
57 "changes" => Ok(OutputComponent::Changes),
58 "grid" => Ok(OutputComponent::Grid),
59 "header" => Ok(OutputComponent::Header),
60 "numbers" => Ok(OutputComponent::Numbers),
61 "snip" => Ok(OutputComponent::Snip),
62 "full" => Ok(OutputComponent::Full),
63 "plain" => Ok(OutputComponent::Plain),
64 _ => Err(format!("Unknown style '{}'", s).into()),
70pub struct OutputComponents(pub HashSet<OutputComponent>);
72impl OutputComponents {
73 pub fn changes(&self) -> bool {
74 self.0.contains(&OutputComponent::Changes)
77 pub fn grid(&self) -> bool {
78 self.0.contains(&OutputComponent::Grid)
81 pub fn header(&self) -> bool {
82 self.0.contains(&OutputComponent::Header)
85 pub fn numbers(&self) -> bool {
86 self.0.contains(&OutputComponent::Numbers)
89 pub fn snip(&self) -> bool {
90 self.0.contains(&OutputComponent::Snip)
93 pub fn plain(&self) -> bool {
94 self.0.iter().all(|c| c == &OutputComponent::Plain)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list