This commit is contained in:
2025-11-01 20:53:38 +01:00
parent aa8851aca0
commit 6e4452ddb9
12 changed files with 457 additions and 106 deletions

View File

@@ -4,15 +4,18 @@ import (
"context"
"flag"
"fmt"
"mirror-sync/cmd/cli/config"
"mirror-sync/pkg/client"
"mirror-sync/pkg/project"
"os"
"path/filepath"
"github.com/google/subcommands"
)
type (
ApplyCmd struct {
projectName string
}
)
@@ -28,10 +31,22 @@ Options:
}
func (p *ApplyCmd) SetFlags(f *flag.FlagSet) {
wd, err := os.Getwd()
if err != nil {
panic(err)
}
f.StringVar(&p.projectName, "project-name", filepath.Base(wd), "set the project name")
}
func (p *ApplyCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
projectConfig, err := project.LoadCurrent()
clientConfig := config.Load()
defaultValues := project.DefaultValues{
DaemonURL: clientConfig.Deamon.URL,
ProjectName: p.projectName,
}
projectConfig, err := project.LoadCurrent(defaultValues)
if err != nil {
fmt.Fprintf(os.Stderr, "error: %s\n", err)
return subcommands.ExitFailure