Skip to content

Commit 912190f

Browse files
authored
Merge pull request #1853 from wheels-dev/cli-fixes
Cli fixes
2 parents e39d977 + 428e96a commit 912190f

38 files changed

+1805
-1327
lines changed

cli/src/commands/wheels/generate/code.cfc

Lines changed: 437 additions & 0 deletions
Large diffs are not rendered by default.

cli/src/commands/wheels/generate/controller.cfc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ component aliases="wheels g controller" extends="../base" {
5656

5757
if (hasCustomActions) {
5858
// HIGHEST PRIORITY: Custom actions specified
59-
actionList = listToArray(arguments.actions);
59+
actionList = listToArray(trim(arguments.actions));
60+
// Remove empty elements and trim each action
61+
actionList = actionList.map(function(action) {
62+
return trim(action);
63+
}).filter(function(action) {
64+
return len(action) > 0;
65+
});
6066
} else if (arguments.crud) {
6167
if (arguments.api) {
6268
// API: No form actions (new, edit)
@@ -144,4 +150,4 @@ component aliases="wheels g controller" extends="../base" {
144150
setExitCode(1);
145151
}
146152
}
147-
}
153+
}

cli/src/commands/wheels/generate/helper.cfc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,17 +287,17 @@ result = #functionList[1]#("some input");
287287

288288
private string function generateHighlightFunction() {
289289
var content = chr(9) & chr(9) & "// Highlight search terms in text" & chr(10);
290-
content &= chr(9) & chr(9) & "local.searchTerm = arguments.options.term ?: """";" & chr(10);
290+
content &= chr(9) & chr(9) & "local.term = arguments.options.term ?: """";" & chr(10);
291291
content &= chr(9) & chr(9) & "local.highlightClass = arguments.options.class ?: ""highlight"";" & chr(10);
292292
content &= chr(10);
293-
content &= chr(9) & chr(9) & "if (!len(local.searchTerm)) {" & chr(10);
293+
content &= chr(9) & chr(9) & "if (!len(local.term)) {" & chr(10);
294294
content &= chr(9) & chr(9) & chr(9) & "return arguments.value;" & chr(10);
295295
content &= chr(9) & chr(9) & "}" & chr(10);
296296
content &= chr(10);
297297
content &= chr(9) & chr(9) & "return reReplaceNoCase(" & chr(10);
298298
content &= chr(9) & chr(9) & chr(9) & "arguments.value," & chr(10);
299-
content &= chr(9) & chr(9) & chr(9) & """(#local.searchTerm#)""," & chr(10);
300-
content &= chr(9) & chr(9) & chr(9) & """<span class=\""#local.highlightClass#\"">\\1</span>""," & chr(10);
299+
content &= chr(9) & chr(9) & chr(9) & """('' & local.term & '')""," & chr(10);
300+
content &= chr(9) & chr(9) & chr(9) & """<span class=''' & local.highlightClass & '''>\\1</span>""," & chr(10);
301301
content &= chr(9) & chr(9) & chr(9) & """all""" & chr(10);
302302
content &= chr(9) & chr(9) & ");" & chr(10);
303303
return content;

cli/src/commands/wheels/generate/model.cfc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ component aliases='wheels g model' extends="../base" {
131131
name = arguments.name,
132132
properties = parsedProperties,
133133
baseDirectory = getCWD(),
134-
tableName = arguments.tableName
134+
tableName = arguments.tableName,
135+
primaryKey = arguments.primaryKey
135136
);
136137
} else {
137138
var actualTableName = len(arguments.tableName) ? arguments.tableName : helpers.pluralize(lCase(arguments.name));
@@ -176,7 +177,13 @@ component aliases='wheels g model' extends="../base" {
176177
var properties = [];
177178

178179
if (len(arguments.propertiesString)) {
179-
var propList = listToArray(arguments.propertiesString);
180+
var propList = listToArray(trim(arguments.propertiesString));
181+
// Remove empty elements and trim each property
182+
propList = propList.map(function(prop) {
183+
return trim(prop);
184+
}).filter(function(prop) {
185+
return len(prop) > 0;
186+
});
180187

181188
for (var prop in propList) {
182189
var parts = listToArray(prop, ":");
@@ -264,4 +271,4 @@ component aliases='wheels g model' extends="../base" {
264271

265272
return arguments.properties;
266273
}
267-
}
274+
}

0 commit comments

Comments
 (0)