File: lines.rs

package info (click to toggle)
rust-linemux 0.3.0-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 224 kB
  • sloc: sh: 25; makefile: 2
file content (26 lines) | stat: -rw-r--r-- 657 bytes parent folder | download | duplicates (2)
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
//! Demonstrates file event stream for a given set of files.
//!
//! Usage:
//!     lines /path/to/file1 /path/to/file2 ...
//!
//! The files could be present or not, but assume some data will eventually be
//! be written to them in order to generate lines.

use linemux::MuxedLines;

#[tokio::main]
pub async fn main() -> std::io::Result<()> {
    let args: Vec<String> = std::env::args().skip(1).collect();

    let mut lines = MuxedLines::new()?;

    for f in args {
        lines.add_file(&f).await?;
    }

    while let Ok(Some(line)) = lines.next_line().await {
        println!("({}) {}", line.source().display(), line.line());
    }

    Ok(())
}