mirror of
https://github.com/nushell/nushell.git
synced 2025-08-15 21:27:51 +02:00
A bit more infra
This commit is contained in:
21
src/commands/cd.rs
Normal file
21
src/commands/cd.rs
Normal file
@ -0,0 +1,21 @@
|
||||
use crate::errors::ShellError;
|
||||
use crate::object::process::Process;
|
||||
use crate::object::{DirEntry, ShellObject, Value};
|
||||
use derive_new::new;
|
||||
use std::path::{Path, PathBuf};
|
||||
use sysinfo::SystemExt;
|
||||
|
||||
#[derive(new)]
|
||||
pub struct Cd;
|
||||
|
||||
impl crate::Command for Cd {
|
||||
fn run(
|
||||
&mut self,
|
||||
args: Vec<String>,
|
||||
_host: &dyn crate::Host,
|
||||
env: &mut crate::Environment,
|
||||
) -> Result<Value, ShellError> {
|
||||
env.cwd = dunce::canonicalize(env.cwd().join(&args[0]).as_path())?;
|
||||
Ok(Value::nothing())
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ use crate::object::Value;
|
||||
pub trait Command {
|
||||
fn run(
|
||||
&mut self,
|
||||
args: Vec<String>,
|
||||
host: &dyn crate::Host,
|
||||
env: &mut crate::Environment,
|
||||
) -> Result<Value, ShellError>;
|
||||
|
@ -10,6 +10,7 @@ pub struct Ls;
|
||||
impl crate::Command for Ls {
|
||||
fn run(
|
||||
&mut self,
|
||||
_args: Vec<String>,
|
||||
_host: &dyn crate::Host,
|
||||
env: &mut crate::Environment,
|
||||
) -> Result<Value, ShellError> {
|
||||
|
@ -12,6 +12,7 @@ pub struct Ps {
|
||||
impl crate::Command for Ps {
|
||||
fn run(
|
||||
&mut self,
|
||||
_args: Vec<String>,
|
||||
_host: &dyn crate::Host,
|
||||
_env: &mut crate::Environment,
|
||||
) -> Result<Value, ShellError> {
|
||||
|
Reference in New Issue
Block a user