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") templateLines, templateFileUsed := readTemplate(dotenvFile) variables := envbuilder.ParseVariablesOnly(templateLines) contents := strings.Join(templateLines, "") screen := editorScreen if repo.IsInRepo() { if handleExtraEnvVars(variables) { screen = wizardScreen } } m := Model{ initialScreen: screen, DotenvFile: dotenvFile, DotenvTemplate: templateFileUsed, 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: "Edit .env file using setup wizard", 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") templateLines, templateFileUsed := readTemplate(dotenvFile) variables, contents, _ := envbuilder.VariablesFromTemplate(templateLines) m := Model{ initialScreen: wizardScreen, DotenvFile: dotenvFile, DotenvTemplate: templateFileUsed, 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 in .env file", Long: "Automatically populate .env file with fresh Datarobot credentials", 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 = writeUsingTemplateFile(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) templateLines, _ := readTemplate(dotenv) parsedVars := envbuilder.ParseVariablesOnly(templateLines) 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.