Extensions API and tools

7 views
Skip to first unread message

Gelnior

unread,
Mar 7, 2012, 12:12:00 PM3/7/12
to rail...@googlegroups.com
Hi all,

I would like to know how to add tools to railway command line. I have read the section that explains how to do it but I don't know in which file I should put my code for hash railway.tools : 
railway.tools.database = function () { ... }

Do I need to build a whole extension for that or just change a single file ?  

Frank

PS: thanks for this great project.

Anatoliy C.

unread,
Mar 8, 2012, 5:58:26 AM3/8/12
to RailwayJS
Hi Frank!

There are two options:
1) package
2) initializer

First one preferred in case if this code is common and would be shared
between different projects. Second option is for project-wide tools,
just for single project, not common code.

Guidelines.

1. Package

Create regular package, which exports `init` method:

exports.init = function () {
// add tools here
railway.tools.mySuperCoolTool = function () {};
};

2. initializer

Put your code to config/initializers/ directory, for example: config/
initializers/tools.js

railway.tools.mySuperCoolTool = function () {};

Good luck,
Anatoliy

Gelnior

unread,
Mar 8, 2012, 9:40:27 AM3/8/12
to rail...@googlegroups.com
Thank you Anatolly for these informations. I understand better the way it works but I still have a bug. When I write my "tool", it says that railway.args (args too) is undefined. In railway documentation, there is nothing that says how I import args into my tool function. What should I do ?
Reply all
Reply to author
Forward
0 new messages