(id, name, targetPath string)
| 113 | } |
| 114 | |
| 115 | func registerProject(id, name, targetPath string) error { |
| 116 | configPath, err := globalConfigPath() |
| 117 | if err != nil { |
| 118 | return err |
| 119 | } |
| 120 | doc, err := readGlobalConfigNode(configPath) |
| 121 | if err != nil { |
| 122 | return fmt.Errorf("failed to read global config: %w", err) |
| 123 | } |
| 124 | if err := checkDuplicateID(doc, id); err != nil { |
| 125 | return err |
| 126 | } |
| 127 | appendProjectNode(doc, id, name, targetPath) |
| 128 | if err := writeGlobalConfigNode(configPath, doc); err != nil { |
| 129 | return fmt.Errorf("failed to write global config: %w", err) |
| 130 | } |
| 131 | fmt.Printf("Registered project %q at %s\n", id, targetPath) |
| 132 | return nil |
| 133 | } |
| 134 | |
| 135 | func runProjectUnregister(_ *cobra.Command, _ []string) error { |
| 136 | configPath, err := globalConfigPath() |
no test coverage detected