Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AddCmd = &cobra.Command{ Use: "add", Short: "Add new component", Args: cobra.MaximumNArgs(1), Run: func(cmd *cobra.Command, args []string) { root, err := cmd.Flags().GetString("root") if err != nil { color.Red("%s", err) return } var ( categoryId string componentId string ) if len(args) > 0 { id := args[0] idSplit := strings.SplitN(id, ".", 2) categoryId = strings.SplitN(id, ".", 2)[0] if len(idSplit) > 1 { componentId = lo.Must(lo.Last(strings.SplitN(id, ".", 2))) } } if categoryId == "" { err := survey.AskOne(&survey.Select{ Message: "Component Category", Options: components.ComponentCategoryOptions, }, &categoryId) if err != nil { color.Red("%s", err) return } } if componentId == "" { err := survey.AskOne(&survey.Select{ Message: "Select Components", Options: components.ComponentMapping[categoryId], }, &componentId) if err != nil { color.Red("%s", err) return } } categoryId = lo.Capitalize(categoryId) componentId = lo.Capitalize(componentId) err = components.NewConfigService().Add( components.AddArgs{ Component: fmt.Sprintf("%s.%s", categoryId, componentId), Root: root, }, ) if err != nil { color.Red("%s", err) return } }, }
View Source
var InitCmd = &cobra.Command{ Use: "init", Short: "Initialize a new alchemy project", Run: func(cmd *cobra.Command, args []string) { var root string var orm string var databaseProvider string var databaseUrl string var provisionDatabase string err := survey.AskOne(&survey.Input{Message: "Provide alchemy component root: ", Default: "."}, &root) if err != nil { color.Red("%s", err) return } err = survey.AskOne(&survey.Select{Message: "Choose ORM: ", Options: orms.OrmOptions}, &orm) if err != nil { color.Red("%s", err) return } err = survey.AskOne( &survey.Select{ Message: "Choose Database Provider: ", Options: orms.OrmMappings[orm], }, &databaseProvider, ) if err != nil { color.Red("%s", err) return } err = survey.AskOne( &survey.Select{ Message: "Provision Database with Docker Compose: ", Options: []string{"Yes", "No"}, Default: "Yes", }, &provisionDatabase, ) if err != nil { color.Red("%s", err) return } if strings.ToLower(provisionDatabase) == "no" { err = survey.AskOne(&survey.Input{Message: "Provide database url: "}, &databaseUrl) if err != nil { color.Red("%s", err) return } } err = components.NewConfigService().Init(components.InitArgs{ Root: root, Orm: orm, ShouldProvideDatabase: strings.ToLower(provisionDatabase) == "yes", DatabaseUrl: databaseUrl, DatabaseProvider: databaseProvider, }) if err != nil { color.Red("%s", err) return } }, }
View Source
var RemoveCmd = &cobra.Command{ Use: "remove", Short: "Add new component", Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) {}, }
View Source
var RootCmd = &cobra.Command{
Use: "go-alchemy",
Short: "Golang Alchemy CLI",
}
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.