| 133 | } |
| 134 | |
| 135 | func runProjectUnregister(_ *cobra.Command, _ []string) error { |
| 136 | configPath, err := globalConfigPath() |
| 137 | if err != nil { |
| 138 | return err |
| 139 | } |
| 140 | doc, err := readGlobalConfigNode(configPath) |
| 141 | if err != nil { |
| 142 | return fmt.Errorf("failed to read global config: %w", err) |
| 143 | } |
| 144 | matchKey, matchVal, err := resolveUnregisterMatch() |
| 145 | if err != nil { |
| 146 | return err |
| 147 | } |
| 148 | removedID, ok := removeProjectNode(doc, matchKey, matchVal) |
| 149 | if !ok { |
| 150 | return fmt.Errorf("no project found matching %s %q", matchKey, matchVal) |
| 151 | } |
| 152 | if err := writeGlobalConfigNode(configPath, doc); err != nil { |
| 153 | return fmt.Errorf("failed to write global config: %w", err) |
| 154 | } |
| 155 | fmt.Printf("Unregistered project %q\n", removedID) |
| 156 | return nil |
| 157 | } |
| 158 | |
| 159 | func resolveUnregisterMatch() (string, string, error) { |
| 160 | if projectUnregisterID != "" { |