Closed kjdelisle closed 6 years ago
I don't agree. I though the CLI is supposed to follow the style we recommend and I think it's a good idea to add Controller
suffix for class names so it's clear looking at a artifact the type of the artifact.
I don't have strong opinion on either approach. However, when I first use the cli command, i did have the puzzle why it is appending Controller
without telling me.
If we are appending the suffix automatically, something to consider:
I am personally fine with the current solution, where Controller
is appended to the class name. I see how this can be confusing though, I like Diana's proposal to add some sort of a hint - either in the prompt or after accepting the value from the user.
If we decide to recommend a name following a convention, we SHOULD prompt the value so that users can override it.
+1 for allowing users to override the convention if they want but we keep it.
Currently if we run lb4 controller
, we have:
$ lb4 controller
? Controller class name: Test
? What kind of controller would you like to generate? (Use arrow keys)
❯ Empty Controller
REST Controller with CRUD functions
Are we going with:
$ lb4 controller
? Controller name: Test
? Controller class name: (TestController)
? What kind of controller would you like to generate? (Use arrow keys)
I'm not sure how we can better prompt the user for the "first name" to derive the controller class name. Please comment.
As much as I like the above approach, as I was about to edit the issue with the final acceptance criteria I realized that the second prompt is now just a redundant prompt. Are we ok with that?
And I looked at Angular CLI, and for components made using it, they just append the word Component as a suffix like we do with Controller. While it's confusing, I'm wondering if this is really an issue.
If it is, then I'm ok to add a redundant prompt, but if we can avoid it then I'd like to do that. Maybe we just need to change our success message
FROM
Controller ShoppingCart is now created in src/controllers/
TO
Controller ShoppingCartController is now created in src/controllers/shopping-cart.controller.ts
We can possibly add color to the controller name and file name to draw a user's attention using the chalk
module.
+1 for @virkt25 proposal above. I would even remove the first "Controller" word from the message, it feels redundant to me.
ShoppingCartController was created in src/controllers/shopping-cart.controller.ts
Overview
Original Description As a LoopBack 4 user, I would like the CLI tool to respect my naming choice, since I might not want the word
Controller
added to the end of my class name (Foo
->FooController
).Revised Description -- Based on discussion LB4 CLI is opinionated about the approach it takes for generating artifacts based on conventions we recommend / follow. Currently when a
Controller
is generated, users aren't made aware of the fact that we have appended the wordController
to the end of their answer to the prompt asking for aController class name
. We must make it clear to the user the name of the class we've generated.This is the approach we are going with and can be reviewed based on user feedback at a later time.
Acceptance Criteria
[ ] Update the success message of Controller Generator to state the name of the class that was generated. Example:
ShoppingCartController was created in src/controllers/shopping-cart.controller.ts
[ ] Modify all existing tests to match (if any)
[ ] Update the existing documentation to match (if any)