1use std::collections::HashSet;
6#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
7pub enum OutputComponent {
18#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
24impl Default for OutputWrap {
25 fn default() -> Self {
31 pub fn components(self, interactive_terminal: bool) -> &'static [OutputComponent] {
33 OutputComponent::Auto => {
34 if interactive_terminal {
35 OutputComponent::Full.components(interactive_terminal)
37 OutputComponent::Plain.components(interactive_terminal)
40 OutputComponent::Changes => &[OutputComponent::Changes],
41 OutputComponent::Grid => &[OutputComponent::Grid],
42 OutputComponent::Header => &[OutputComponent::Header],
43 OutputComponent::Numbers => &[OutputComponent::Numbers],
44 OutputComponent::Snip => &[OutputComponent::Snip],
45 OutputComponent::Full => &[
46 OutputComponent::Changes,
47 OutputComponent::Grid,
48 OutputComponent::Header,
49 OutputComponent::Numbers,
50 OutputComponent::Snip,
52 OutputComponent::Plain => &[],
57impl FromStr for OutputComponent {
60 fn from_str(s: &str) -> Result<Self> {
62 "auto" => Ok(OutputComponent::Auto),
63 "changes" => Ok(OutputComponent::Changes),
64 "grid" => Ok(OutputComponent::Grid),
65 "header" => Ok(OutputComponent::Header),
66 "numbers" => Ok(OutputComponent::Numbers),
67 "snip" => Ok(OutputComponent::Snip),
68 "full" => Ok(OutputComponent::Full),
69 "plain" => Ok(OutputComponent::Plain),
70 _ => Err(format!("Unknown style '{}'", s).into()),
75#[derive(Debug, Clone, Default)]
76pub struct OutputComponents(pub HashSet<OutputComponent>);
78impl OutputComponents {
79 pub fn new(components: &[OutputComponent]) -> OutputComponents {
80 OutputComponents(components.iter().cloned().collect())
83 pub fn changes(&self) -> bool {
84 self.0.contains(&OutputComponent::Changes)
87 pub fn grid(&self) -> bool {
88 self.0.contains(&OutputComponent::Grid)
91 pub fn header(&self) -> bool {
92 self.0.contains(&OutputComponent::Header)
95 pub fn numbers(&self) -> bool {
96 self.0.contains(&OutputComponent::Numbers)
99 pub fn snip(&self) -> bool {
100 self.0.contains(&OutputComponent::Snip)
103 pub fn plain(&self) -> bool {
104 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