Files
Harry dc53c0b3e3 feat: add env command to output shell commands for PATH configuration
- Introduced a new `env` command that outputs the necessary shell command to add the current working directory to the user's PATH.
- Updated the `runInit` function to inform users about the new `env` command for adding tools to PATH.

This update enhances the CLI by providing users with a convenient way to configure their environment for tool usage.
2026-01-04 11:38:47 +08:00

25 lines
455 B
Go

package command
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
var EnvCmd = &cobra.Command{
Use: "env",
Short: "Output shell commands to add tools to PATH",
Long: `Output export command for eval. Usage: eval "$(dify env)"`,
Run: runEnv,
}
func runEnv(cmd *cobra.Command, args []string) {
dir, err := os.Getwd()
if err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
fmt.Printf("export PATH=\"%s:$PATH\"\n", dir)
}