2021-04-22 09:36:11 +00:00
|
|
|
package config
|
|
|
|
|
2021-04-22 10:54:17 +00:00
|
|
|
import "fmt"
|
|
|
|
|
2023-02-25 15:44:26 +00:00
|
|
|
type ConfigDemo struct {
|
2023-02-25 15:07:37 +00:00
|
|
|
ConfigApps
|
2021-04-22 09:36:11 +00:00
|
|
|
}
|
|
|
|
|
2023-02-25 15:44:26 +00:00
|
|
|
var _ Config = (*ConfigDemo)(nil)
|
2021-04-22 09:36:11 +00:00
|
|
|
|
2023-02-25 15:44:26 +00:00
|
|
|
func (c *ConfigDemo) Install() error {
|
2021-05-05 09:37:38 +00:00
|
|
|
for _, app := range c.Apps {
|
2021-04-22 10:54:17 +00:00
|
|
|
for _, p := range app.Paths {
|
2022-10-24 14:57:44 +00:00
|
|
|
if p.External == "" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2023-02-25 15:36:50 +00:00
|
|
|
fmt.Printf("Replace [%s] -> [%s]\n", p.Internal, p.External)
|
2021-04-22 10:54:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-22 09:36:11 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-02-25 15:44:26 +00:00
|
|
|
func (c *ConfigDemo) Update() error {
|
2021-05-05 09:37:38 +00:00
|
|
|
for _, app := range c.Apps {
|
2021-04-22 10:54:17 +00:00
|
|
|
for _, p := range app.Paths {
|
2022-10-24 14:57:44 +00:00
|
|
|
if p.External == "" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2023-02-25 15:36:50 +00:00
|
|
|
fmt.Printf("Replace [%s] -> [%s]\n", p.External, p.Internal)
|
2021-04-22 10:54:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-22 09:36:11 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-02-25 15:44:26 +00:00
|
|
|
func (c *ConfigDemo) Download() error {
|
2022-10-24 14:57:44 +00:00
|
|
|
for _, app := range c.Apps {
|
|
|
|
for _, p := range app.Paths {
|
|
|
|
if p.URL == "" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2023-02-25 15:36:50 +00:00
|
|
|
fmt.Printf("Download [%s] -> [%s]\n", p.URL, p.Internal)
|
2022-10-24 14:57:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-02-25 15:44:26 +00:00
|
|
|
func (c *ConfigDemo) Clean() error {
|
2021-05-05 09:37:38 +00:00
|
|
|
unusedDirs, err := getUnusedDirs(c.Apps)
|
2021-04-22 10:54:17 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
for dir := range unusedDirs {
|
2023-02-25 15:36:50 +00:00
|
|
|
fmt.Printf("Remove [%s]\n", dir)
|
2021-04-22 10:54:17 +00:00
|
|
|
}
|
|
|
|
|
2021-04-22 09:36:11 +00:00
|
|
|
return nil
|
|
|
|
}
|
2021-04-23 03:21:48 +00:00
|
|
|
|
2023-02-25 15:44:26 +00:00
|
|
|
func (c *ConfigDemo) Diff() error {
|
2021-04-23 03:21:48 +00:00
|
|
|
return nil
|
|
|
|
}
|
2023-02-25 15:30:20 +00:00
|
|
|
|
2023-02-25 15:44:26 +00:00
|
|
|
func (c *ConfigDemo) Validate() error {
|
2023-02-25 15:30:20 +00:00
|
|
|
return nil
|
|
|
|
}
|