-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up builtin commands and update README.
- Loading branch information
Showing
8 changed files
with
38 additions
and
79 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
@@ -1,63 +1,38 @@ | ||
use crate::{CmdEnv, CmdResult}; | ||
use log::*; | ||
use std::io::{Read, Write}; | ||
use std::path::PathBuf; | ||
use std::io::Write; | ||
|
||
#[doc(hidden)] | ||
pub fn builtin_echo(env: &mut CmdEnv) -> CmdResult { | ||
pub(crate) fn builtin_echo(env: &mut CmdEnv) -> CmdResult { | ||
let msg = env.args()[1..].join(" "); | ||
writeln!(env.stdout(), "{}", msg) | ||
} | ||
|
||
#[doc(hidden)] | ||
pub fn builtin_die(env: &mut CmdEnv) -> CmdResult { | ||
pub(crate) fn builtin_die(env: &mut CmdEnv) -> CmdResult { | ||
error!("FATAL: {}", env.args()[1..].join(" ")); | ||
std::process::exit(1); | ||
} | ||
|
||
#[doc(hidden)] | ||
pub fn builtin_error(env: &mut CmdEnv) -> CmdResult { | ||
pub(crate) fn builtin_error(env: &mut CmdEnv) -> CmdResult { | ||
error!("{}", env.args()[1..].join(" ")); | ||
Ok(()) | ||
} | ||
|
||
#[doc(hidden)] | ||
pub fn builtin_warn(env: &mut CmdEnv) -> CmdResult { | ||
pub(crate) fn builtin_warn(env: &mut CmdEnv) -> CmdResult { | ||
warn!("{}", env.args()[1..].join(" ")); | ||
Ok(()) | ||
} | ||
|
||
#[doc(hidden)] | ||
pub fn builtin_info(env: &mut CmdEnv) -> CmdResult { | ||
pub(crate) fn builtin_info(env: &mut CmdEnv) -> CmdResult { | ||
info!("{}", env.args()[1..].join(" ")); | ||
Ok(()) | ||
} | ||
|
||
#[doc(hidden)] | ||
pub fn builtin_debug(env: &mut CmdEnv) -> CmdResult { | ||
pub(crate) fn builtin_debug(env: &mut CmdEnv) -> CmdResult { | ||
debug!("{}", env.args()[1..].join(" ")); | ||
Ok(()) | ||
} | ||
|
||
#[doc(hidden)] | ||
pub fn builtin_trace(env: &mut CmdEnv) -> CmdResult { | ||
pub(crate) fn builtin_trace(env: &mut CmdEnv) -> CmdResult { | ||
trace!("{}", env.args()[1..].join(" ")); | ||
Ok(()) | ||
} | ||
|
||
#[doc(hidden)] | ||
pub fn builtin_cat(env: &mut CmdEnv) -> CmdResult { | ||
if env.args().len() == 1 { | ||
let mut buf = vec![]; | ||
env.stdin().read_to_end(&mut buf)?; | ||
env.stdout().write_all(&buf)?; | ||
return Ok(()); | ||
} | ||
|
||
let mut file = PathBuf::from(env.args()[1].to_owned()); | ||
if file.is_relative() { | ||
file = PathBuf::from(env.current_dir()).join(file); | ||
} | ||
env.stdout().write_all(&std::fs::read(file)?)?; | ||
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
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