mirror of
https://github.com/nushell/nushell.git
synced 2025-08-18 20:29:06 +02:00
Can remove files and directories.
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
use std::path::PathBuf;
|
||||
#![allow(dead_code)]
|
||||
|
||||
pub use std::path::PathBuf;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! nu {
|
||||
($out:ident, $cwd:expr, $commands:expr) => {
|
||||
use std::error::Error;
|
||||
use std::io::prelude::*;
|
||||
use std::process::{Command, Stdio};
|
||||
pub use std::io::prelude::*;
|
||||
pub use std::process::{Command, Stdio};
|
||||
pub use std::error::Error;
|
||||
|
||||
let commands = &*format!(
|
||||
"
|
||||
@@ -75,6 +77,22 @@ macro_rules! nu_error {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn create_file_at(full_path: &str) {
|
||||
std::fs::write(PathBuf::from(full_path), "fake data".as_bytes()).expect("can not create file");
|
||||
}
|
||||
|
||||
pub fn file_exists_at(full_path: &str) -> bool {
|
||||
PathBuf::from(full_path).exists()
|
||||
}
|
||||
|
||||
pub fn delete_directory_at(full_path: &str) {
|
||||
std::fs::remove_dir_all(PathBuf::from(full_path)).expect("can not remove directory");
|
||||
}
|
||||
|
||||
pub fn create_directory_at(full_path: &str) {
|
||||
std::fs::create_dir(PathBuf::from(full_path)).expect("can not create directory");
|
||||
}
|
||||
|
||||
pub fn executable_path() -> PathBuf {
|
||||
let mut buf = PathBuf::new();
|
||||
buf.push("target");
|
||||
|
Reference in New Issue
Block a user