/
buildconfig.go
87 lines (75 loc) · 3.05 KB
/
buildconfig.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package cmd
import (
"fmt"
"encoding/json"
"github.com/golangspell/golangspell-mongodb/config"
"github.com/golangspell/golangspell/domain"
"github.com/spf13/cobra"
)
func init() {
RunCommandFunctions["build-config"] = runBuildConfigCommand
}
func runBuildConfigCommand(cmd *cobra.Command, args []string) {
configBytes, err := json.MarshalIndent(buildSpellConfig(), "", " ")
if err != nil {
panic(err)
}
fmt.Println(string(configBytes))
}
func buildSpellConfig() domain.Spell {
return domain.Spell{
Name: "golangspell-mongodb",
URL: "github.com/golangspell/golangspell-mongodb",
Version: config.Version,
Commands: map[string]*domain.Command{
"build-config": &domain.Command{
Name: "build-config",
ShortDescription: "Builds the config necessary for adding this plugin to the Golang Spell tool",
LongDescription: `Builds the config necessary for adding this plugin to the Golang Spell tool.
This command must be available in all Golang Spell plugins to make it possible the plugin addition to the platform.
Syntax:
golangspell build-config
`,
},
"golangspell-mongodb-hello": &domain.Command{
Name: "golangspell-mongodb-hello",
ShortDescription: "The golangspell-mongodb-hello says Hello! using your new Golangspell base structure",
LongDescription: `The golangspell-mongodb-hello says Hello! using your new Golangspell base structure
The Architectural Model is based in the Clean Architecture and is the basis to add more resources like domain models and repositories.
You can use this as a template to create your own commands.
Please notice that ALL your commands must be prefixed with the name of your Spell (golangspell-mongodb). It will avoid name colision with the Spells from other authors
Args:
name: Your name (required) to be added to the Hello!. Example: Elvis"
Syntax:
golangspell golangspell-mongodb-hello [name]
`,
ValidArgs: []string{"name"},
},
"mongodbinit": &domain.Command{
Name: "mongodbinit",
ShortDescription: "The mongodbinit initializes the application with the Mongo DB infrastructure",
LongDescription: `The mongodbinit initializes the application with the Mongo DB infrastructure
Args:
DatabaseName: indicates the name of the database to connect with
Syntax:
golangspell mongodbinit [DatabaseName]
Examples:
golangspell mongodbinit mydatabase`,
ValidArgs: []string{"DatabaseName"},
},
"mongodbaddcrud": &domain.Command{
Name: "mongodbaddcrud",
ShortDescription: "The mongodbaddcrud command adds a new CRUD for the provided domain entity",
LongDescription: `The mongodbaddcrud command adds a new CRUD for the provided domain entity
The necessary controller, usecase, domain and repository classes are generated by this command
Args:
domainentity: The name (camel case) of the new domain entity which will be generated with the respective controller, usecase and repository
Syntax:
golangspell mongodbaddcrud [YourNewEntityName]
Examples:
golangspell mongodbaddcrud Product`,
ValidArgs: []string{"domainentity"},
},
},
}
}