(appName string)
| 118 | } |
| 119 | |
| 120 | func (c *Config) Remove(appName string) error { |
| 121 | var ( |
| 122 | idx int |
| 123 | found bool |
| 124 | ) |
| 125 | for i, app := range c.Apps { |
| 126 | if appName == app.Name { |
| 127 | found = true |
| 128 | idx = i |
| 129 | break |
| 130 | } |
| 131 | } |
| 132 | if !found { |
| 133 | return fmt.Errorf("application %q doesn't exist", appName) |
| 134 | } |
| 135 | |
| 136 | if c.Default == appName { |
| 137 | c.Default = "" |
| 138 | } |
| 139 | |
| 140 | c.Apps = append(c.Apps[:idx], c.Apps[idx+1:]...) |
| 141 | |
| 142 | viper.Set("default", c.Default) |
| 143 | viper.Set("apps", c.Apps) |
| 144 | return viper.WriteConfig() |
| 145 | } |
| 146 | |
| 147 | func (c *Config) SetDefault(appName string) error { |
| 148 | if c.Default == appName { |
no outgoing calls