-
Notifications
You must be signed in to change notification settings - Fork 9
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
1 parent
eeab94c
commit 3a20581
Showing
5 changed files
with
136 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,31 @@ | ||
use std::ffi::OsString; | ||
|
||
use deno_task_shell::{ExecuteResult, ShellCommand, ShellCommandContext}; | ||
use futures::future::LocalBoxFuture; | ||
use uu_date::uumain as uu_date; | ||
|
||
pub struct DateCommand; | ||
|
||
impl ShellCommand for DateCommand { | ||
fn execute(&self, mut context: ShellCommandContext) -> LocalBoxFuture<'static, ExecuteResult> { | ||
Box::pin(futures::future::ready(match execute_date(&mut context) { | ||
Ok(_) => ExecuteResult::from_exit_code(0), | ||
Err(exit_code) => ExecuteResult::from_exit_code(exit_code), | ||
})) | ||
} | ||
} | ||
|
||
fn execute_date(context: &mut ShellCommandContext) -> Result<(), i32> { | ||
let mut args: Vec<OsString> = vec![OsString::from("date")]; | ||
|
||
context | ||
.args | ||
.iter() | ||
.for_each(|arg| args.push(OsString::from(arg))); | ||
|
||
let exit_code = uu_date(args.into_iter()); | ||
if exit_code != 0 { | ||
return Err(exit_code); | ||
} | ||
Ok(()) | ||
} |
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