Nativescript-cli: Add template prompt for tns create

Created on 17 Feb 2016  Â·  11Comments  Â·  Source: NativeScript/nativescript-cli

Now that we have a lot of templates available I think we should do more to expose them. The --template option is great but it’s somewhat hidden, and I don’t think people will find most of the templates we have out there.

I propose that we add a prompt to tns create that asks which template you’d like to start with if you don’t provide the --template option. Something like this:

$ tns create foo
What template would you like to start with?
[1] Hello world (a minimal starting point)
[2] Master/detail
[3] Tab view
[4] TypeScript hello world
[5] Angular 2
$ Your selection: [ ]

Thoughts?

feature

Most helpful comment

Since we’re about to release a new suite of starting templates, I think this feature is somewhat essential to ensure that our users find these templates we’re putting out there. Here’s my more up-to-date suggestion for how this could work.

> tns create MyApp

Which template would you like to start with?

   [1] JavaScript — Master/Detail
   [2] JavaScript — Drawer Navigation
   [3] JavaScript — Tab Navigation
   [4] TypeScript — Master/Detail
   [5] TypeScript — Drawer Navigation
   [6] TypeScript — Tab Navigation
>  [7] Angular    — Master/Detail
   [8] Angular    — Drawer Navigation
   [9] Angular    — Tab Navigation

All set! Documentation for the “Angular—Master/detail” template is available at https://github.com/NativeScript/template-master-detail-ng/tree/myankov/readme.

Use “cd MyApp” to get started developing your new app!

We could also consider breaking that up into two separate questions—aka ask JS vs. TS vs. ng first, then ask master/detail vs. tabs vs. drawer next—although I think that might be a bit much.

Regardless though I think we need something like this to expose all the new templates we now have.

All 11 comments

+1

-1
Sorry, I like being able to quickly create a test project using the default template. Maybe if they provide the --template option without a template name, it should prompt for it...

:+1: BUT with a caveat. I don't think Angular 2 should be a lone template. All of the listed templates should be available as Angular 2 flavors with something like a ng flag on the command line.

Just to throw a simpler idea out there, we could simply add on to the informational message we already spit out with tns create.

From:
“Project foo was successfully created”

To:
“Project foo was successfully created using the Blank template. Start with alternative templates using tns create --template”

:+1: for Project foo was successfully created using the Blank template. Start with alternative templates using tns create --template

Maybe we can list all available templates when you call tns create without project name? In this case the developer will be able to choose which template to be used when creating the project and later (answering to second question) specify the project name.

Since we’re about to release a new suite of starting templates, I think this feature is somewhat essential to ensure that our users find these templates we’re putting out there. Here’s my more up-to-date suggestion for how this could work.

> tns create MyApp

Which template would you like to start with?

   [1] JavaScript — Master/Detail
   [2] JavaScript — Drawer Navigation
   [3] JavaScript — Tab Navigation
   [4] TypeScript — Master/Detail
   [5] TypeScript — Drawer Navigation
   [6] TypeScript — Tab Navigation
>  [7] Angular    — Master/Detail
   [8] Angular    — Drawer Navigation
   [9] Angular    — Tab Navigation

All set! Documentation for the “Angular—Master/detail” template is available at https://github.com/NativeScript/template-master-detail-ng/tree/myankov/readme.

Use “cd MyApp” to get started developing your new app!

We could also consider breaking that up into two separate questions—aka ask JS vs. TS vs. ng first, then ask master/detail vs. tabs vs. drawer next—although I think that might be a bit much.

Regardless though I think we need something like this to expose all the new templates we now have.

@tjvantoll I think the idea to provide the user with options about what template to use is great, and I also believe there needs to be a separation between js and ts templates. Having said that, I believe there's no need for further separation like: master/detail vs. tabs vs drawer next.

@Plamen5kov I do worry that there are a whole ton of options now, and the CLI repo is probably not the greatest place for this list to live for maintenance purposes.

Way earlier in this thread I suggested that we use a simple message, and we could still go with that approach. Something like...


$ tns create MyApp

Project MyApp was successfully created using the JavaScript—Blank template.
View a full list of starter templates at https://docs.nativescript.org/starter-templates/.

Use cd MyApp to get started developing your new app!


With this approach we could create a big list of the templates on the docs, which would be a heck of a lot easier to maintain. cc @sebawita, as I know he wanted to be involved in how we document these new templates.

I am actually thinking of creating a custom CLI extension (just as a temporary solution) that would let us search and create the templates :)

tns template list
tns template new ProjName

Closing in favor of #3829 🙂

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bradmartin picture bradmartin  Â·  3Comments

erjdriver picture erjdriver  Â·  3Comments

farfromrefug picture farfromrefug  Â·  3Comments

NickIliev picture NickIliev  Â·  3Comments

charsleysa picture charsleysa  Â·  3Comments