mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
use a generic Write instance for command output
This commit is contained in:
parent
6b550e7516
commit
7d17740ca8
13 changed files with 154 additions and 46 deletions
|
@ -1,24 +1,31 @@
|
|||
use crate::usage::Usage;
|
||||
use failure::Fallible;
|
||||
use std::io;
|
||||
use termcolor::WriteColor;
|
||||
|
||||
pub(crate) fn execute(command_name: String, summary: bool) -> Fallible<()> {
|
||||
pub(crate) fn execute<W: WriteColor>(
|
||||
w: &mut W,
|
||||
command_name: String,
|
||||
summary: bool,
|
||||
) -> Fallible<()> {
|
||||
let usage = Usage::new();
|
||||
usage.write_help(io::stdout(), command_name, summary)?;
|
||||
usage.write_help(w, command_name, summary)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::invocation::cmd::test::*;
|
||||
|
||||
#[test]
|
||||
fn test_summary() {
|
||||
execute("task".to_owned(), true).unwrap();
|
||||
let mut w = test_writer();
|
||||
execute(&mut w, "task".to_owned(), true).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_long() {
|
||||
execute("task".to_owned(), false).unwrap();
|
||||
let mut w = test_writer();
|
||||
execute(&mut w, "task".to_owned(), false).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue