config

package
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AddProjectPathCmd = &cobra.Command{
	Use:   "add-path [project_name]",
	Short: "Save project path to be used with start command",
	Long:  "",
	Args:  cobra.ExactArgs(1),
	Run: func(cmd *cobra.Command, args []string) {
		token, workspaceId := utils.GetTogglConfig()
		projectName := args[0]
		currentPath, err := os.Getwd()
		if err != nil {
			fmt.Println("Error getting current path:", err)
			return
		}

		client := api.NewAPIClient(token)

		var projectId int
		if projectName != "" {
			projectId, err = client.GetProjectIdByName(workspaceId, projectName)
			if err != nil {
				log.Fatal("Failed to get project ID:", err)
			}
		}

		viper.Set(fmt.Sprintf("projects.%s.id", projectName), projectId)

		key := fmt.Sprintf("projects.%s.paths", projectName)
		existingPaths := viper.GetStringSlice(key)

		for _, p := range existingPaths {
			if p == currentPath {
				fmt.Println("Path already exists for this project.")
				return
			}
		}
		existingPaths = append(existingPaths, currentPath)

		viper.Set(key, existingPaths)

		if err := viper.WriteConfig(); err != nil {
			log.Fatal("Error saving configuration:", err)
		}

		fmt.Println("Configuration saved successfully!")
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL