Documentation
¶
Index ¶
- Variables
- func Execute() error
- func GetCmdTelemetryData(cmd *cobra.Command, flags []string) map[string]interface{}
- func PostRun(cmd *cobra.Command, cmdErr error, telemetryService telemetry.TelemetryService, ...)
- func PreRun(rootCmd *cobra.Command, args []string, telemetryEnabled bool, clientId string, ...) (telemetry.TelemetryService, *cobra.Command, []string, bool, error)
- func RunInitialScreenFlow(cmd *cobra.Command, args []string) error
- func SetupRootCommand(cmd *cobra.Command)
Constants ¶
This section is empty.
Variables ¶
View Source
var AutoCompleteCmd = &cobra.Command{
Use: "autocomplete [bash|zsh|fish|powershell]",
Short: "Adds completion script for your shell enviornment",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
shell := args[0]
homeDir, err := os.UserHomeDir()
if err != nil {
return fmt.Errorf("error finding user home directory: %s", err)
}
var filePath, profilePath string
switch shell {
case "bash":
filePath = filepath.Join(homeDir, ".daytona.completion_script.bash")
profilePath = filepath.Join(homeDir, ".bashrc")
case "zsh":
filePath = filepath.Join(homeDir, ".daytona.completion_script.zsh")
profilePath = filepath.Join(homeDir, ".zshrc")
case "fish":
filePath = filepath.Join(homeDir, ".config", "fish", "daytona.completion_script.fish")
profilePath = filepath.Join(homeDir, ".config", "fish", "config.fish")
case "powershell":
filePath = filepath.Join(homeDir, "daytona.completion_script.ps1")
profilePath = filepath.Join(homeDir, "Documents", "WindowsPowerShell", "Microsoft.PowerShell_profile.ps1")
default:
return errors.New("unsupported shell type. Please use bash, zsh, fish, or powershell")
}
file, err := os.Create(filePath)
if err != nil {
return fmt.Errorf("error creating completion script file: %s", err)
}
defer file.Close()
switch shell {
case "bash":
err = cmd.Root().GenBashCompletion(file)
case "zsh":
err = cmd.Root().GenZshCompletion(file)
case "fish":
err = cmd.Root().GenFishCompletion(file, true)
case "powershell":
err = cmd.Root().GenPowerShellCompletionWithDesc(file)
}
if err != nil {
return fmt.Errorf("error generating completion script: %s", err)
}
sourceCommand := fmt.Sprintf("\nsource %s\n", filePath)
if shell == "powershell" {
sourceCommand = fmt.Sprintf(". %s\n", filePath)
}
alreadyPresent := false
profile, err := os.ReadFile(profilePath)
if err != nil && !os.IsNotExist(err) {
fmt.Printf("error while reading profile (%s): %s\n", profilePath, err)
}
if strings.Contains(string(profile), strings.TrimSpace(sourceCommand)) {
alreadyPresent = true
}
if !alreadyPresent {
profile, err := os.OpenFile(profilePath, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0644)
if err != nil {
return fmt.Errorf("error opening profile file (%s): %s", profilePath, err)
}
defer profile.Close()
if _, err := profile.WriteString(sourceCommand); err != nil {
return fmt.Errorf("error writing to profile file (%s): %s", profilePath, err)
}
}
fmt.Println("Autocomplete script generated and injected successfully.")
fmt.Printf("Please source your %s profile to apply the changes or restart your terminal.\n", shell)
fmt.Printf("For manual sourcing, use: source %s\n", profilePath)
if shell == "bash" {
fmt.Println("Please make sure that you have bash-completion installed in order to get full autocompletion functionality.")
fmt.Println("On how to install bash-completion, please refer to the following link: https://www.daytona.io/docs/tools/cli/#daytona-autocomplete")
}
return nil
},
}
View Source
var DocsCmd = &cobra.Command{
Use: "docs",
Short: "Opens the Daytona documentation in your default browser.",
Args: cobra.NoArgs,
Aliases: []string{"documentation", "doc"},
RunE: func(cmd *cobra.Command, args []string) error {
output := views.GetBoldedInfoMessage("Opening the Daytona documentation in your default browser. If opening fails, you can go to " + linkStyle.Render(docsURL) + " manually.")
fmt.Println(output)
return browser.OpenURL(docsURL)
},
}
Functions ¶
func GetCmdTelemetryData ¶ added in v0.35.0
func GetCmdTelemetryData(cmd *cobra.Command, flags []string) map[string]interface{}
func PostRun ¶ added in v0.35.0
func PostRun(cmd *cobra.Command, cmdErr error, telemetryService telemetry.TelemetryService, clientId string, startTime time.Time, endTime time.Time, flags []string)
func PreRun ¶ added in v0.35.0
func PreRun(rootCmd *cobra.Command, args []string, telemetryEnabled bool, clientId string, startTime time.Time) (telemetry.TelemetryService, *cobra.Command, []string, bool, error)
func RunInitialScreenFlow ¶ added in v0.15.0
func RunInitialScreenFlow(cmd *cobra.Command, args []string) error
func SetupRootCommand ¶ added in v0.15.0
func SetupRootCommand(cmd *cobra.Command)
Types ¶
This section is empty.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.