Skip to main content

command_stream/commands/
pwd.rs

1//! Virtual `pwd` command implementation
2
3use crate::commands::CommandContext;
4use crate::utils::CommandResult;
5
6/// Execute the pwd command
7///
8/// Prints the current working directory.
9pub async fn pwd(ctx: CommandContext) -> CommandResult {
10    let path = ctx.get_cwd();
11    CommandResult::success(format!("{}\n", path.display()))
12}
13
14#[cfg(test)]
15mod tests {
16    use super::*;
17
18    #[tokio::test]
19    async fn test_pwd() {
20        let ctx = CommandContext::new(vec![]);
21        let result = pwd(ctx).await;
22        assert!(result.is_success());
23        assert!(!result.stdout.is_empty());
24    }
25}