Skip to content

Commit

Permalink
fix: added targeting to init also
Browse files Browse the repository at this point in the history
  • Loading branch information
demeyerthom committed Dec 10, 2024
1 parent b255a53 commit 6a1af59
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/src/reference/cli/mach-composer_init.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ mach-composer init [flags]
-h, --help help for init
--ignore-version Skip MACH composer version check
-o, --output-path string Outputs path to store the generated files. (default "deployments")
-s, --site string Site to parse. If not set parse all sites.
--var-file string Use a variable file to parse the configuration with.
-w, --workers int The number of workers to use (default 1)
```
Expand Down
7 changes: 6 additions & 1 deletion internal/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import (
"github.com/mach-composer/mach-composer-cli/internal/runner"
)

var initFlags struct {
site string
}

var initCmd = &cobra.Command{
Use: "init",
Short: "Initialize site directories Terraform files.",
Expand All @@ -28,14 +32,15 @@ var initCmd = &cobra.Command{

func init() {
registerCommonFlags(initCmd)
initCmd.Flags().StringVarP(&initFlags.site, "site", "s", "", "Site to parse. If not set parse all sites.")
}

func initFunc(cmd *cobra.Command, _ []string) error {
cfg := loadConfig(cmd, true)
defer cfg.Close()
ctx := cmd.Context()

dg, err := graph.ToDeploymentGraph(cfg, commonFlags.outputPath)
dg, err := graph.ToDeploymentGraph(cfg, commonFlags.outputPath, graph.WithTargetSiteName(initFlags.site))
if err != nil {
return err
}
Expand Down

0 comments on commit 6a1af59

Please sign in to comment.