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
pub mod commands;
pub mod config;
pub mod err_msg_parse;
pub mod errlog;
pub mod gh;
pub mod issue;
pub mod util;

/// Module containing macros related to protocol words.
pub mod macros {
    #[macro_export]
    // These macros are needed because the normal ones panic when there's a broken pipe.
    // This is especially problematic for CLI tools that are frequently piped into `head` or `grep -q`
    macro_rules! pipe_println {
        () => (print!("\n"));
        ($fmt:expr) => ({
            writeln!(std::io::stdout(), $fmt)
        });
        ($fmt:expr, $($arg:tt)*) => ({
            writeln!(std::io::stdout(), $fmt, $($arg)*)
        })
    }
    pub use pipe_println;

    #[macro_export]
    macro_rules! pipe_print {
        () => (print!("\n"));
        ($fmt:expr) => ({
            write!(std::io::stdout(), $fmt)
        });
        ($fmt:expr, $($arg:tt)*) => ({
            write!(std::io::stdout(), $fmt, $($arg)*)
        })
    }

    pub use pipe_print;
}