Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var EditCmd = &cobra.Command{ Use: "edit", Short: "✏️ Edit .env file using built-in editor", RunE: func(cmd *cobra.Command, _ []string) error { if viper.GetBool("debug") { f, err := tea.LogToFile("tea-debug.log", "debug") if err != nil { fmt.Println("fatal:", err) os.Exit(1) } defer f.Close() } cwd, err := os.Getwd() if err != nil { return err } dotenvFile := filepath.Join(cwd, ".env") dotenvFileLines, contents := readDotenvFile(dotenvFile) variables := envbuilder.ParseVariablesOnly(dotenvFileLines) screen := editorScreen if repo.IsInRepo() { if handleExtraEnvVars(variables) { screen = wizardScreen } } m := Model{ initialScreen: screen, DotenvFile: dotenvFile, variables: variables, contents: contents, SuccessCmd: tea.Quit, } p := tea.NewProgram( tui.NewInterruptibleModel(m), tea.WithAltScreen(), tea.WithContext(cmd.Context()), ) _, err = p.Run() return err }, }
View Source
var SetupCmd = &cobra.Command{ Use: "setup", Short: "🧙 Environment configuration wizard", Long: `Launch the interactive environment configuration wizard. This wizard will help you: 1️⃣ Review required environment variables 2️⃣ Configure API keys and credentials 3️⃣ Set up database connections (if needed) 4️⃣ Validate your configuration 💡 Perfect for first-time setup or when adding new integrations.`, PreRunE: func(cmd *cobra.Command, _ []string) error { return auth.EnsureAuthenticatedE(cmd.Context()) }, Run: func(cmd *cobra.Command, _ []string) { if viper.GetBool("debug") { f, err := tea.LogToFile("tea-debug.log", "debug") if err != nil { fmt.Println("fatal:", err) os.Exit(1) } defer f.Close() } repositoryRoot, err := ensureInRepo() if err != nil { os.Exit(1) } dotenvFile := filepath.Join(repositoryRoot, ".env") dotenvFileLines, _ := readDotenvFile(dotenvFile) variables, contents := envbuilder.VariablesFromLines(dotenvFileLines) m := Model{ initialScreen: wizardScreen, DotenvFile: dotenvFile, variables: variables, contents: contents, SuccessCmd: tea.Quit, } p := tea.NewProgram( tui.NewInterruptibleModel(m), tea.WithAltScreen(), tea.WithContext(cmd.Context()), ) _, err = p.Run() if err != nil { fmt.Printf("Error: %v\n", err) os.Exit(1) } }, }
View Source
var UpdateCmd = &cobra.Command{ Use: "update", Short: "🔄 Automatically update DataRobot credentials", Long: `Automatically update your .env file with fresh DataRobot credentials. This command will: • Refresh your DataRobot API credentials • Update environment variables automatically • Preserve your existing custom settings 💡 Use this when your credentials expire or you need to refresh your connection.`, PreRunE: func(cmd *cobra.Command, _ []string) error { return auth.EnsureAuthenticatedE(cmd.Context()) }, Run: func(_ *cobra.Command, _ []string) { dotenv, err := ensureInRepoWithDotenv() if err != nil { os.Exit(1) } _, _, err = updateDotenvFile(dotenv) if err != nil { log.Error(err) os.Exit(1) } }, }
View Source
var ValidateCmd = &cobra.Command{ Use: "validate", Short: "Validate .env and environment variable configuration against required settings", Run: func(_ *cobra.Command, _ []string) { dotenv, err := ensureInRepoWithDotenv() if err != nil { os.Exit(1) } repoRoot := filepath.Dir(dotenv) dotenvFileLines, _ := readDotenvFile(dotenv) parsedVars := envbuilder.ParseVariablesOnly(dotenvFileLines) result := envbuilder.ValidateEnvironment(repoRoot, parsedVars) varStyle := lipgloss.NewStyle().Foreground(tui.DrPurple).Bold(true) valueStyle := lipgloss.NewStyle().Foreground(tui.DrGreen) fmt.Println("\nValidating required variables:") for _, valResult := range result.Results { if valResult.Valid { fmt.Printf(" %s: %s\n", varStyle.Render(valResult.Field), valueStyle.Render(valResult.Value)) } } if result.HasErrors() { fmt.Println("\nValidation errors:") for _, valResult := range result.Results { if !valResult.Valid { fmt.Printf("\n%s: required variable %s is not set\n", tui.ErrorStyle.Render("Error"), varStyle.Render(valResult.Field)) if valResult.Help != "" { fmt.Printf(" Description: %s\n", valResult.Help) } fmt.Println(" Set this variable in your .env file or run `dr dotenv setup` to configure it.") } } os.Exit(1) } fmt.Println("\nValidation passed: all required variables are set.") }, }
Functions ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.