Incoming: BrowserCMS commandline script
In 3.1, it should be a bit easier to create a new BrowserCMS project. The new gem will come with a command line script which should simplify the syntax associated with project creation. Here’s how it works.
Old 3.0 style
Instead of writing this somewhat ungainly command:
rails my_project -m http://browsercms.org/templates/blank.rb
New 3.1 style
You will be able to type:
browsercms my_project
This will create a blank BrowserCMS project, just like the first script. It’s basically just a simplifying wrapper around the rails command.
For the very lazy (like me)
And if ten characters is really just too much to type for you, the following will work as well.
bcms my_project
Modules, Demo and rails options
In most cases, developers want to create blank projects, which is what the browsercms command does. The two next most common use cases are:
- Creating a demo project (which contains some more detailed sample templates and data)
- Creating a module (which creates a skeleton for a packagable BrowserCMS module).
In addition, the majority of the rail’s commandline options are still available (like -d and –force), so you can still pass the same options in. Here’s some examples:
Demos for the new folks
browsercms demo_site -m demo
This creates the project using the demo application template. What we have done is overload the application template option (-m) to allow a short hand version (demo) rather than have to specify the full path.
Creating a module
The same is also true for creating modules, like so:
browsercms bcms_fancy_module -m module -d mysql --freeze
This creates a module project. Here we show off how the standard rails options work, so this project will use mysql database and freeze Rails into the vendor/rails directory, via the -d and --freeze options.
Get some help
You can run browsercms to get help on what options the command supports.
Benefits of having a script
There are few reasons why we decided to add the new script, starting with the most obvious:
- It’s shorter to type and easier to remember: Even I had to look the exact syntax for the 3.0 command, so a worst this change is about my bad memory.
- We can provide help/documentation: By having a script, we can make things more discoverable for new developers as well as provide examples/options for returning users.
- Removes the external dependancy on browsercms.org: By creating a script, we can look up and use the blank.rb template from within the gem, rather than needing to download it from the browsercms.org website
- Handle multiple versions of templates: One major problem with the 3.0 syntax is that we couldn’t make changes to say, blank.rb, without breaking backwards compatibility. All versions of browsercms were using the same template file. By using the templates packaging with each gem, we avoid the need for silly workarounds.
Requiring developers to remember which version of a template to use would be asking for trouble. The following would certainly have worked, but is needlessly complicated.
rails my_project -m http://browsercms.org/template/3.0.4/blank.rb
In Conclusion
So that’s the new command line script that will be available for 3.1. It’s available current in the master branch on github for folks to play around with. Over the next few weeks, I plan to add more articles here about upcoming features and changes from 3.1, so stay tuned.
-
[...] This post was mentioned on Twitter by browsercms, peakpg. peakpg said: Coming in #browsercms 3.1: New nicer syntax for creating projects. Just type 'browsercms project_name'. See http://bit.ly/6aJUdy for more. [...]

Love it!