pub struct CdMove<'a> {
pub target: &'a str,
pub args: &'a [String],
pub pwd: &'a Path,
pub prev: Option<&'a Path>,
pub dest: Option<&'a Path>,
pub ctx: &'a Ctx<'a>,
}Expand description
One attempted (or completed) cd, with everything a clause may need to judge it.
Fields§
§target: &'a strThe first non-option argument of cd: "" for a bare cd, "-" for cd -.
args: &'a [String]All arguments of cd, options included, for custom rules.
pwd: &'a PathThe logical directory the player is in before the move, as the shell reports it.
prev: Option<&'a Path>The shell’s previous directory, used to resolve cd - before the move.
dest: Option<&'a Path>After the move only: the logical $PWD the shell ended up in.
ctx: &'a Ctx<'a>The situation: workspace, section root, home, level.
Implementations§
Source§impl<'a> CdMove<'a>
impl<'a> CdMove<'a>
Sourcepub fn new(
ctx: &'a Ctx<'a>,
target: &'a str,
args: &'a [String],
pwd: &'a Path,
) -> Self
pub fn new( ctx: &'a Ctx<'a>, target: &'a str, args: &'a [String], pwd: &'a Path, ) -> Self
A move about to happen: no previous directory, no destination yet.
Sourcepub fn with_prev(self, prev: Option<&'a Path>) -> Self
pub fn with_prev(self, prev: Option<&'a Path>) -> Self
Set the shell’s previous directory (what cd - goes to).
Sourcepub fn with_dest(self, dest: &'a Path) -> Self
pub fn with_dest(self, dest: &'a Path) -> Self
Set the directory the shell actually ended up in (a move that has happened).
Sourcepub fn destination(&self) -> Option<PathBuf>
pub fn destination(&self) -> Option<PathBuf>
Where the move goes, as the shell’s logical $PWD will read.
After the move this is CdMove::dest as given. Before it, the target is resolved
the way cd -L does: "" is $HOME, - is the previous directory, an absolute
target is itself, anything else is relative to pwd; then . and .. are resolved
lexically (no symlink is followed). None when it cannot be known: cd - without a
previous directory, or a relative target with no usable pwd.