-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
1,034 additions
and
77 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "uu_last" | ||
version = "0.0.1" | ||
edition = "2021" | ||
|
||
[lib] | ||
path = "src/last.rs" | ||
|
||
[dependencies] | ||
uucore = { workspace = true, features = ["utmpx"] } | ||
clap = { workspace = true} | ||
dns-lookup = { workspace = true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# last | ||
|
||
``` | ||
Usage: | ||
[options] [<username>...] [<tty>...] | ||
``` | ||
|
||
Show a listing of last logged in users. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// This file is part of the uutils util-linux package. | ||
// | ||
// For the full copyright and license information, please view the LICENSE | ||
// file that was distributed with this source code. | ||
|
||
use clap::{crate_version, Arg, ArgAction, Command}; | ||
use uucore::{format_usage, help_about, help_usage}; | ||
|
||
mod platform; | ||
|
||
mod options { | ||
pub const SYSTEM: &str = "system"; | ||
pub const HOSTLAST: &str = "hostlast"; | ||
pub const NO_HOST: &str = "nohostname"; | ||
pub const LIMIT: &str = "limit"; | ||
pub const DNS: &str = "dns"; | ||
pub const TIME_FORMAT: &str = "time-format"; | ||
pub const USER_TTY: &str = "username"; | ||
pub const FILE: &str = "file"; | ||
} | ||
|
||
const ABOUT: &str = help_about!("last.md"); | ||
const USAGE: &str = help_usage!("last.md"); | ||
|
||
#[uucore::main] | ||
use platform::uumain; | ||
|
||
pub fn uu_app() -> Command { | ||
Command::new(uucore::util_name()) | ||
.version(crate_version!()) | ||
.about(ABOUT) | ||
.override_usage(format_usage(USAGE)) | ||
.infer_long_args(true) | ||
.arg( | ||
Arg::new(options::FILE) | ||
.short('f') | ||
.long("file") | ||
.action(ArgAction::Set) | ||
.default_value("/var/log/wtmp") | ||
.help("use a specific file instead of /var/log/wtmp") | ||
.required(false), | ||
) | ||
.arg( | ||
Arg::new(options::SYSTEM) | ||
.short('x') | ||
.long(options::SYSTEM) | ||
.action(ArgAction::SetTrue) | ||
.required(false) | ||
.help("display system shutdown entries and run level changes"), | ||
) | ||
.arg( | ||
Arg::new(options::DNS) | ||
.short('d') | ||
.long(options::DNS) | ||
.action(ArgAction::SetTrue) | ||
.required(false) | ||
.help("translate the IP number back into a hostname"), | ||
) | ||
.arg( | ||
Arg::new(options::HOSTLAST) | ||
.short('a') | ||
.long(options::HOSTLAST) | ||
.action(ArgAction::SetTrue) | ||
.required(false) | ||
.help("display hostnames in the last column"), | ||
) | ||
.arg( | ||
Arg::new(options::NO_HOST) | ||
.short('R') | ||
.long(options::NO_HOST) | ||
.action(ArgAction::SetTrue) | ||
.required(false) | ||
.help("don't display the hostname field"), | ||
) | ||
.arg( | ||
Arg::new(options::LIMIT) | ||
.short('n') | ||
.long(options::LIMIT) | ||
.action(ArgAction::Set) | ||
.required(false) | ||
.help("how many lines to show") | ||
.value_parser(clap::value_parser!(i32)) | ||
.allow_negative_numbers(true), | ||
) | ||
.arg( | ||
Arg::new(options::TIME_FORMAT) | ||
.long(options::TIME_FORMAT) | ||
.action(ArgAction::Set) | ||
.required(false) | ||
.help("show timestamps in the specified <format>: notime|short|full|iso") | ||
.default_value("short"), | ||
) | ||
.arg(Arg::new(options::USER_TTY).action(ArgAction::Append)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uucore::bin!(uu_last); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// This file is part of the uutils util-linux package. | ||
// | ||
// For the full copyright and license information, please view the LICENSE | ||
// file that was distributed with this source code. | ||
|
||
#[cfg(unix)] | ||
mod unix; | ||
#[cfg(unix)] | ||
pub use self::unix::*; | ||
|
||
#[cfg(target_os = "openbsd")] | ||
mod openbsd; | ||
#[cfg(target_os = "openbsd")] | ||
pub use self::openbsd::*; | ||
|
||
#[cfg(windows)] | ||
mod windows; | ||
#[cfg(windows)] | ||
pub use self::windows::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// This file is part of the uutils util-linux package. | ||
// | ||
// For the full copyright and license information, please view the LICENSE | ||
// file that was distributed with this source code. | ||
|
||
// Specific implementation for OpenBSD: tool unsupported (utmpx not supported) | ||
|
||
use crate::uu_app; | ||
|
||
use uucore::error::UResult; | ||
|
||
pub fn uumain(args: impl uucore::Args) -> UResult<()> { | ||
let _matches = uu_app().try_get_matches_from(args)?; | ||
|
||
println!("unsupported command on OpenBSD"); | ||
Ok(()) | ||
} |
Oops, something went wrong.