Skip to content

Commit

Permalink
tail: Cleanup imports
Browse files Browse the repository at this point in the history
cherry pick
  • Loading branch information
Joining7943 committed Sep 18, 2022
1 parent f8c9de7 commit 7e7f82c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 23 deletions.
2 changes: 2 additions & 0 deletions src/uu/tail/src/chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
//! or at the end of piped stdin with [`LinesChunk`] or [`BytesChunk`].
//!
//! Use [`ReverseChunks::new`] to create a new iterator over chunks of bytes from the file.

// spell-checker:ignore (ToDO) filehandle BUFSIZ

use std::collections::VecDeque;
use std::fs::File;
use std::io::{BufRead, Read, Seek, SeekFrom, Write};
Expand Down
1 change: 0 additions & 1 deletion src/uu/tail/src/follow/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use std::collections::hash_map::Keys;
use std::collections::HashMap;
use std::fs::{File, Metadata};
use std::io::{stdout, BufRead, BufReader, BufWriter};

use std::path::{Path, PathBuf};
use uucore::error::UResult;

Expand Down
4 changes: 2 additions & 2 deletions src/uu/tail/src/follow/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ use notify::{RecommendedWatcher, RecursiveMode, Watcher, WatcherKind};
use std::collections::VecDeque;
use std::io::BufRead;
use std::path::{Path, PathBuf};
use std::sync::mpsc;
use std::sync::mpsc::{channel, Receiver};
use std::sync::mpsc::{self, channel, Receiver};
use uucore::display::Quotable;
use uucore::error::{set_exit_code, UResult, USimpleError};

Expand Down Expand Up @@ -91,6 +90,7 @@ pub struct WatcherService {
/// platform specific event driven method. Since `use_polling` is subject to
/// change during runtime it is moved out of [`Settings`].
pub use_polling: bool,

pub watcher_rx: Option<WatcherRx>,
pub orphans: Vec<PathBuf>,
pub files: FileHandling,
Expand Down
16 changes: 4 additions & 12 deletions src/uu/tail/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,16 @@

// spell-checker:ignore tailable seekable stdlib (stdlib)

#[cfg(unix)]
use std::os::unix::fs::{FileTypeExt, MetadataExt};

use crate::args::Settings;
use crate::text;
use std::collections::VecDeque;
use std::fs::{File, Metadata};
use std::io::{Seek, SeekFrom};
#[cfg(unix)]
use std::os::unix::fs::{FileTypeExt, MetadataExt};
use std::path::{Path, PathBuf};

use uucore::error::UResult;

use crate::args::Settings;
use crate::text;

// * This file is part of the uutils coreutils package.
// *
// * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code.

#[derive(Debug, Clone)]
pub enum InputKind {
File(PathBuf),
Expand Down
14 changes: 6 additions & 8 deletions src/uu/tail/src/tail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,19 @@ mod paths;
mod platform;
pub mod text;

pub use args::uu_app;
use args::{parse_args, FilterMode, Settings, Signum};
use chunks::ReverseChunks;
use follow::WatcherService;
use paths::{FileExtTail, Input, InputKind, InputService, MetadataExtTail};
use same_file::Handle;
use std::cmp::Ordering;
use std::fs::File;
use std::io::{self, stdin, stdout, BufRead, BufReader, BufWriter, Read, Seek, SeekFrom, Write};
use std::path::{Path, PathBuf};

use uucore::display::Quotable;
use uucore::error::{get_exit_code, set_exit_code, FromIo, UError, UResult, USimpleError};

pub use args::uu_app;
use args::{parse_args, FilterMode, Settings, Signum};
use chunks::ReverseChunks;
use follow::WatcherService;
use paths::{FileExtTail, Input, InputKind, InputService, MetadataExtTail};

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let settings = parse_args(args)?;
Expand Down Expand Up @@ -96,7 +94,6 @@ fn uu_tail(settings: &Settings) -> UResult<()> {
the input file is not a FIFO, pipe, or regular file, it is unspecified whether or
not the -f option shall be ignored.
*/

if !input_service.has_only_stdin() {
follow::follow(watcher_service, settings)?;
}
Expand Down Expand Up @@ -196,6 +193,7 @@ fn tail_file(
}

fn tail_stdin(
// TODO: remove settings
settings: &Settings,
input_service: &mut InputService,
input: &Input,
Expand Down

0 comments on commit 7e7f82c

Please sign in to comment.