github.com/krzko/gosh@v0.0.0-20241128233202-5abd4ef06633/internal/shell/builtins/pwd.go (about)

     1  // internal/shell/builtins/pwd.go
     2  package builtins
     3  
     4  import (
     5  	"fmt"
     6  	"os"
     7  )
     8  
     9  type PwdCommand struct{}
    10  
    11  func (p *PwdCommand) Execute(args []string) error {
    12  	dir, err := os.Getwd()
    13  	if err != nil {
    14  		return err
    15  	}
    16  	fmt.Println(dir)
    17  	return nil
    18  }
    19  
    20  func (p *PwdCommand) Help() string {
    21  	return "pwd: Print working directory\nUsage: pwd"
    22  }