wall initial implementation - #578
Conversation
|
nice |
…test into the library
…test into the library
|
a few jobs are failing |
|
Yes sorry I updated the pr by error, I still need to work on this |
There was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Introduces an initial implementation of the wall utility as a new optional workspace crate, along with basic CLI parsing and a small set of utility-specific tests.
Changes:
- Adds new
uu_wallcrate (library + binary) and wires it into workspace features/dependencies - Implements Unix-only
walllogic: message sourcing (stdin/args/file), scanning logged-in users viautmpx, and writing to ttys - Adds initial tests and minor formatting/import cleanups in existing test files
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/tests.rs | Registers the wall test module behind the wall feature flag |
| tests/by-util/test_wall.rs | Adds initial cross-platform tests for wall behavior |
| tests/by-util/test_setsid.rs | Adjusts import ordering (no functional change) |
| tests/by-util/test_lslocks.rs | Reflows an array literal for formatting (no functional change) |
| src/uu/wall/wall.md | Adds minimal help/about text for wall |
| src/uu/wall/src/wall.rs | Implements the core wall command logic and CLI definition |
| src/uu/wall/src/main.rs | Adds binary entrypoint using uucore::bin! |
| src/uu/wall/Cargo.toml | Adds new crate manifest and dependencies for uu_wall |
| Cargo.toml | Enables wall as an optional workspace feature/dependency |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| let matches = uucore::clap_localization::handle_clap_result(uu_app(), args) | ||
| .map_err(|e| USimpleError::new(1, e.to_string()))?; // Clap would have return 101 | ||
| // Might be considered wrong for --help and --version |
|
|
||
| let user = env::var_os(user).unwrap_or_default(); | ||
| // Fetch the TTY of the process calling wall (requires OS-specific calls or a wrapper function) | ||
| let tty = &get_sender(); |
| #[error("wall: cannot read stdin")] | ||
| Stdin(#[from] io::Error), |
| fn read_from_file(file: &OsString) -> Result<String, WallError> { | ||
| let mut buffer = Vec::new(); | ||
| let mut file = std::fs::File::open(file)?; |
| let datetime = get_hour_and_date(); | ||
| #[cfg(target_os = "macos")] | ||
| return format!( | ||
| "\r\nBroadcast message from {}@{} ({tty}) at ({datetime} \r\n\r\n", |
| .long(OPT_NOBANNER) | ||
| .required(false) | ||
| .action(ArgAction::SetTrue) | ||
| .help("Suppress the intro branner of the broadcast"), |
| [dependencies] | ||
| chrono = { workspace = true } | ||
| clap.workspace = true | ||
| nix = { workspace = true, features = ["feature", "fs", "hostname", "term"] } |
| #[cfg(target_os = "linux")] | ||
| #[test] | ||
| fn test_invalid_file() { | ||
| new_ucmd!().arg("not_existing_file.not_existing_extension"); // Should print non-file name as broadcast |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 10 changed files in this pull request and generated 7 comments.
Suppressed comments (8)
src/uu/wall/Cargo.toml:19
- The nix dependency enables a feature named "feature", which doesn’t appear to be used elsewhere in this workspace and is likely not a valid nix crate feature; this can cause Cargo feature resolution failures.
chrono = { workspace = true }
clap.workspace = true
nix = { workspace = true, features = ["feature", "fs", "hostname", "term"] }
thiserror.workspace = true
src/uu/wall/src/wall.rs:40
- WallError::Stdin is used via
#[from] io::Error, so file-open/read errors also get reported as "cannot read stdin". Consider using a more general message so file input failures aren’t mislabeled.
enum WallError {
#[error("wall: cannot read stdin")]
Stdin(#[from] io::Error),
#[error("wall: encoding error")]
src/uu/wall/src/wall.rs:58
handle_clap_result(...).map_err(|e| USimpleError::new(1, ...))forces exit code 1 for clap’s help/version output and other parsing errors. Other utilities in this repo rely ontry_get_matches_from(args)?so clap/help uses the expected exit codes.
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)
.map_err(|e| USimpleError::new(1, e.to_string()))?; // Clap would have return 101
// Might be considered wrong for --help and --version
let message = get_message(matches.get_many(STRING).unwrap_or_default())?;
src/uu/wall/src/wall.rs:122
- Same as the Linux cfg: prefer
Command::new(uucore::util_name())to follow the established pattern across utilities and keep the displayed name consistent.
pub fn uu_app() -> Command {
Command::new("wall")
.version(uucore::crate_version!())
src/uu/wall/src/wall.rs:101
- Typo in user-facing help text: "branner" → "banner".
.required(false)
.action(ArgAction::SetTrue)
.help("Suppress the intro branner of the broadcast"),
)
src/uu/wall/src/wall.rs:133
- Same user-facing help text issue here (ungrammatical).
.value_name("GROUP")
.help("Send restrict to only users in the group(s)")
.num_args(1)
src/uu/wall/src/wall.rs:218
- On macOS the broadcast header format string is missing the closing ")" after the datetime, which makes the output inconsistent with Linux and likely incorrect.
"\r\nBroadcast message from {}@{} ({tty}) at ({datetime} \r\n\r\n",
tests/by-util/test_wall.rs:24
- This test doesn’t assert anything, so it may not actually execute the command (unlike the other tests in this directory which call
.succeeds()/.fails()). Add an explicit expectation so the test verifies behavior on Linux.
fn test_invalid_file() {
new_ucmd!().arg("not_existing_file.not_existing_extension"); // Should print non-file name as broadcast
}
| // 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. |
| // 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. |
| pub fn uu_app() -> Command { | ||
| Command::new("wall") | ||
| .version(uucore::crate_version!()) |
| .value_name("GROUP") | ||
| .help("Send restrict to only users in the group(s)") | ||
| .num_args(1) |
| let biding = unistd::gethostname().unwrap_or_else(|_| "".into()); | ||
| let hostname = biding.to_string_lossy(); | ||
|
|
| write!(file, "{transmission}").map_err(|e| { | ||
| eprintln!("wall-error: terminal write:, {e}",); | ||
| WallError::Stdin(e) | ||
| })?; |
| @@ -0,0 +1 @@ | |||
| wall - write message to all users | |||
This pull request introduces an implementation of the 'wall' utility. It aims to be a first-draft binary crate since the flags of the wall command are not implemented yet.
New utility implementation:
CLI and mechanics: