(appName string)
| 145 | } |
| 146 | |
| 147 | func (c *Config) SetDefault(appName string) error { |
| 148 | if c.Default == appName { |
| 149 | // if already default, early return |
| 150 | return nil |
| 151 | } |
| 152 | |
| 153 | var found bool |
| 154 | for _, app := range c.Apps { |
| 155 | if appName == app.Name { |
| 156 | found = true |
| 157 | break |
| 158 | } |
| 159 | } |
| 160 | if !found { |
| 161 | return fmt.Errorf("application %q doesn't exist", appName) |
| 162 | } |
| 163 | |
| 164 | c.Default = appName |
| 165 | viper.Set("default", c.Default) |
| 166 | return viper.WriteConfig() |
| 167 | } |
| 168 | |
| 169 | func GetConfig(cmd *cobra.Command) *Config { |
| 170 | cfg := &Config{} |
no outgoing calls