Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Compiled Go binaries
# Replace 'bootstrapper' with your actual executable name
bootstrap
c.out
coverage.out

# Project folders generated by your tool
# This pattern will ignore any folders starting with "new_project"
Expand Down
63 changes: 63 additions & 0 deletions cmd/apply.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package cmd

import (
"fmt"
"strconv"

"github.com/spf13/cobra"
"github.com/upsaurav12/bootstrap/pkg/parser"
)

var applyCmd = cobra.Command{
Use: "apply",
Short: "Apply project configuration from YAML",
Run: func(cmd *cobra.Command, args []string) {

if yamlPath == "" {
fmt.Fprintln(cmd.OutOrStdout(), "Error: --yaml is required")
return
}

yamlConfig, err := parser.ReadYAML(yamlPath)
if err != nil {
fmt.Fprintln(cmd.OutOrStdout(), "error reading yaml:", err)
return
}

YAMLPath = yamlPath
projectRouter = yamlConfig.Project.Router
projectPort = strconv.Itoa(yamlConfig.Project.Port)
DBType = yamlConfig.Project.Database
Entities = yamlConfig.Entities

createNewProject(
yamlConfig.Project.Name,
projectRouter,
yamlConfig.Project.Type,
cmd.OutOrStdout(),
)
},
}

var yamlPath string

type Config struct {
Project Project `yaml:"project"`
Entities []string `yaml:"entities"`
CustomLogic []string `yaml:"custom_logic"`
}

type Project struct {
Name string `yaml:"name"`
Type string `yaml:"type"`
Port int `yaml:"port"`
Location string `yaml:"location"`
Database string `yaml:"db"`
Router string `yaml:"router"`
}

func init() {

applyCmd.Flags().StringVar(&yamlPath, "yaml", "", "yaml configuation")
rootCmd.AddCommand(&applyCmd)
}
Loading