Remove config-migrate command
This commit is contained in:
parent
854e756016
commit
9d74397512
7 changed files with 0 additions and 565 deletions
|
|
@ -1,63 +0,0 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/cli"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/config"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/config/legacy"
|
||||
)
|
||||
|
||||
// ConfigMigrate is the config-migrate command
|
||||
var ConfigMigrate wisski_distillery.Command = cfgMigrate{}
|
||||
|
||||
type cfgMigrate struct {
|
||||
Positionals struct {
|
||||
Input string `positional-arg-name:"input" required:"1-1" description:"old config to migrate"`
|
||||
} `positional-args:"true"`
|
||||
}
|
||||
|
||||
func (cfgMigrate) Description() wisski_distillery.Description {
|
||||
return wisski_distillery.Description{
|
||||
Requirements: cli.Requirements{
|
||||
NeedsDistillery: false,
|
||||
},
|
||||
Command: "config_migrate",
|
||||
Description: "migrate legacy configuration",
|
||||
}
|
||||
}
|
||||
|
||||
func (c cfgMigrate) Run(context wisski_distillery.Context) error {
|
||||
// open the legacy file
|
||||
file, err := os.Open(c.Positionals.Input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
// migrate from a legacy configuration
|
||||
// then marshal, and re-read
|
||||
|
||||
var cfg config.Config
|
||||
// migrate the legacy config
|
||||
if err := legacy.Migrate(&cfg, file); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// validate it!
|
||||
if err := cfg.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// marshal the config
|
||||
bytes, err := config.Marshal(&cfg, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// and print it!
|
||||
fmt.Println(string(bytes))
|
||||
return nil
|
||||
}
|
||||
|
|
@ -18,7 +18,6 @@ var wdcli = wisski_distillery.NewProgram()
|
|||
func init() {
|
||||
// self commands
|
||||
wdcli.Register(cmd.Config)
|
||||
wdcli.Register(cmd.ConfigMigrate)
|
||||
wdcli.Register(cmd.License)
|
||||
|
||||
// setup commands
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue