Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: optimize make commands #597

Merged
merged 5 commits into from
Aug 14, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix test cases
hwbrzzl committed Aug 12, 2024

Verified

This commit was signed with the committer’s verified signature.
MakisH Gerasimos Chourdakis
commit a1fd8ba8cb6d4cc3dcb02d33f5f2e5a5917aacb7
4 changes: 2 additions & 2 deletions database/console/model_make_command.go
Original file line number Diff line number Diff line change
@@ -44,13 +44,13 @@ func (receiver *ModelMakeCommand) Extend() command.Extend {

// Handle Execute the console command.
func (receiver *ModelMakeCommand) Handle(ctx console.Context) error {
make, err := supportconsole.NewMake(ctx, "model", ctx.Argument(0), filepath.Join("app", "models"))
m, err := supportconsole.NewMake(ctx, "model", ctx.Argument(0), filepath.Join("app", "models"))
if err != nil {
color.Red().Println(err)
return nil
}

if err := file.Create(make.GetFilePath(), receiver.populateStub(receiver.getStub(), make.GetPackageName(), make.GetStructName())); err != nil {
if err := file.Create(m.GetFilePath(), receiver.populateStub(receiver.getStub(), m.GetPackageName(), m.GetStructName())); err != nil {
return err
}

24 changes: 0 additions & 24 deletions support/console/console.go
Original file line number Diff line number Diff line change
@@ -81,27 +81,3 @@ func (m *Make) GetFolderPath() string {

return folderPath
}

func GetName(ctx console.Context, ttype, name string, getPath func(string) string) (string, error) {
if name == "" {
var err error
name, err = ctx.Ask(fmt.Sprintf("Enter the %s name", ttype), console.AskOption{
Validate: func(s string) error {
if s == "" {
return fmt.Errorf("the %s name cannot be empty", ttype)
}

return nil
},
})
if err != nil {
return "", err
}
}

if !ctx.OptionBool("force") && file.Exists(getPath(name)) {
return "", fmt.Errorf("the %s already exists. Use the --force or -f flag to overwrite", ttype)
}

return name, nil
}
2 changes: 1 addition & 1 deletion validation/console/filter_make_command.go
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ func (receiver *FilterMakeCommand) Extend() command.Extend {

// Handle Execute the console command.
func (receiver *FilterMakeCommand) Handle(ctx console.Context) error {
m, err := supportconsole.NewMake(ctx, "event", ctx.Argument(0), filepath.Join("app", "filters"))
m, err := supportconsole.NewMake(ctx, "filter", ctx.Argument(0), filepath.Join("app", "filters"))
if err != nil {
color.Red().Println(err)
return nil
2 changes: 1 addition & 1 deletion validation/console/rule_make_command.go
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ func (receiver *RuleMakeCommand) Extend() command.Extend {

// Handle Execute the console command.
func (receiver *RuleMakeCommand) Handle(ctx console.Context) error {
m, err := supportconsole.NewMake(ctx, "event", ctx.Argument(0), filepath.Join("app", "rules"))
m, err := supportconsole.NewMake(ctx, "rule", ctx.Argument(0), filepath.Join("app", "rules"))
if err != nil {
color.Red().Println(err)
return nil