Skip to content

Commit bb6e27f

Browse files
committed
short cli flags
1 parent 230a910 commit bb6e27f

File tree

3 files changed

+48
-13
lines changed

3 files changed

+48
-13
lines changed

blueprint-ui/cmd/web/components/folderstructure.templ

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ type OptionsStruct struct {
99
SelectedDB string
1010
SelectGit string
1111
AdvancedOptions []string
12+
ShortFlags bool
1213
}
1314

1415
func contains(slice []string, value string) bool {

blueprint-ui/cmd/web/components/form.templ

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
package components
2+
23
import "strings"
34

45
type FeatureTuple struct {
@@ -7,24 +8,42 @@ type FeatureTuple struct {
78
}
89

910
func GetCommandString(options OptionsStruct) string {
11+
var command string
12+
1013
projectName := strings.ReplaceAll(options.ProjectName, " ", "_")
1114
if projectName == "" {
1215
projectName = "my_project"
1316
}
14-
command := "go-blueprint create --name " + projectName + " --framework " + options.SelectedBackend
15-
if options.SelectedDB != "none" {
16-
command += " --driver " + options.SelectedDB
17-
} else {
18-
command += " --driver none"
19-
}
20-
if len(options.AdvancedOptions) > 0 {
21-
command += " --advanced"
22-
}
23-
for _, opt := range options.AdvancedOptions {
24-
command += " --feature " + opt
25-
}
17+
if options.ShortFlags { // Short format when toggle is checked
18+
command = "go-blueprint create -n " + projectName + " -f " + options.SelectedBackend
19+
if options.SelectedDB != "none" {
20+
command += " -d " + options.SelectedDB
21+
} else {
22+
command += " -d none"
23+
}
24+
if len(options.AdvancedOptions) > 0 {
25+
command += " -a"
26+
}
27+
for _, opt := range options.AdvancedOptions {
28+
command += " --feature " + opt
29+
}
30+
command += " -g " + options.SelectGit
2631

27-
command += " --git " + options.SelectGit
32+
} else { // Long format (default)
33+
command = "go-blueprint create --name " + projectName + " --framework " + options.SelectedBackend
34+
if options.SelectedDB != "none" {
35+
command += " --driver " + options.SelectedDB
36+
} else {
37+
command += " --driver none"
38+
}
39+
if len(options.AdvancedOptions) > 0 {
40+
command += " --advanced"
41+
}
42+
for _, opt := range options.AdvancedOptions {
43+
command += " --feature " + opt
44+
}
45+
command += " --git " + options.SelectGit
46+
}
2847

2948
return command
3049
}
@@ -71,6 +90,20 @@ var options = OptionsStruct{
7190

7291
templ Form() {
7392
<form class="space-y-2" hx-boost="true" action="/update_structure" hx-trigger="submit" hx-target="#results">
93+
<div class="flex justify-end mb-4">
94+
<label class="inline-flex items-center cursor-pointer">
95+
<input
96+
type="checkbox"
97+
id="shortFlags"
98+
name="shortFlags"
99+
class="sr-only peer"
100+
hx-post="/update_structure"
101+
hx-target="#results"
102+
/>
103+
<div class="relative w-11 h-6 bg-gray-300 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-indigo-200 rounded-full peer peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-indigo-600"></div>
104+
<span class="ms-3 text-sm font-medium text-gray-900">Short CLI Flags</span>
105+
</label>
106+
</div>
74107
<div class="mt-4">
75108
<label
76109
for="projectName"

blueprint-ui/cmd/web/update_structure.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ func UpdateStructureHandler(w http.ResponseWriter, r *http.Request) {
7171
SelectedDB: r.FormValue("database"),
7272
SelectGit: r.FormValue("git"),
7373
AdvancedOptions: filteredOptions,
74+
ShortFlags: r.FormValue("shortFlags") == "on",
7475
}
7576

7677
commandStr := components.GetCommandString(options)

0 commit comments

Comments
 (0)