mirror of
https://github.com/correl/rebar.git
synced 2024-11-23 19:19:54 +00:00
Add a library template
This commit is contained in:
parent
b97677c2c2
commit
c83d037404
7 changed files with 51 additions and 0 deletions
|
@ -21,6 +21,7 @@ _rebar()
|
||||||
compile \
|
compile \
|
||||||
create \
|
create \
|
||||||
create-app \
|
create-app \
|
||||||
|
create-lib \
|
||||||
create-node \
|
create-node \
|
||||||
ct \
|
ct \
|
||||||
doc \
|
doc \
|
||||||
|
|
|
@ -31,6 +31,7 @@ _rebar () {
|
||||||
'compile[Compile sources]' \
|
'compile[Compile sources]' \
|
||||||
'create[Create skel based on template and vars]' \
|
'create[Create skel based on template and vars]' \
|
||||||
'create-app[Create simple app skel]' \
|
'create-app[Create simple app skel]' \
|
||||||
|
'create-lib[Create simple lib skel]' \
|
||||||
'create-node[Create simple node skel]' \
|
'create-node[Create simple node skel]' \
|
||||||
'list-template[List avaiavle templates]' \
|
'list-template[List avaiavle templates]' \
|
||||||
'doc[Generate Erlang program documentation]' \
|
'doc[Generate Erlang program documentation]' \
|
||||||
|
|
14
priv/templates/simplelib.app.src
Normal file
14
priv/templates/simplelib.app.src
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{application, {{libid}},
|
||||||
|
[
|
||||||
|
{description, "An Erlang {{libid}} library"},
|
||||||
|
{vsn, "1"},
|
||||||
|
{modules, [
|
||||||
|
{{libid}}
|
||||||
|
]},
|
||||||
|
{registered, []},
|
||||||
|
{applications, [
|
||||||
|
kernel,
|
||||||
|
stdlib
|
||||||
|
]},
|
||||||
|
{env, []}
|
||||||
|
]}.
|
20
priv/templates/simplelib.erl
Normal file
20
priv/templates/simplelib.erl
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
%% See LICENSE for licensing information.
|
||||||
|
%% -*- coding: utf-8 -*-
|
||||||
|
-module({{libid}}).
|
||||||
|
|
||||||
|
%% {{libid}}: {{libid}} library's entry point.
|
||||||
|
|
||||||
|
-export([my_func/0]).
|
||||||
|
|
||||||
|
|
||||||
|
%% API
|
||||||
|
|
||||||
|
my_func() ->
|
||||||
|
ok().
|
||||||
|
|
||||||
|
%% Internals
|
||||||
|
|
||||||
|
ok() ->
|
||||||
|
ok.
|
||||||
|
|
||||||
|
%% End of Module.
|
3
priv/templates/simplelib.template
Normal file
3
priv/templates/simplelib.template
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{variables, [{libid, "mylib"}]}.
|
||||||
|
{template, "simplelib.app.src", "src/{{libid}}.app.src"}.
|
||||||
|
{template, "simplelib.erl", "src/{{libid}}.erl"}.
|
|
@ -338,6 +338,7 @@ escriptize Generate escript archive
|
||||||
|
|
||||||
create template= [var=foo,...] Create skel based on template and vars
|
create template= [var=foo,...] Create skel based on template and vars
|
||||||
create-app [appid=myapp] Create simple app skel
|
create-app [appid=myapp] Create simple app skel
|
||||||
|
create-lib [libid=mylib] Create simple lib skel
|
||||||
create-node [nodeid=mynode] Create simple node skel
|
create-node [nodeid=mynode] Create simple node skel
|
||||||
list-templates List available templates
|
list-templates List available templates
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
-module(rebar_templater).
|
-module(rebar_templater).
|
||||||
|
|
||||||
-export(['create-app'/2,
|
-export(['create-app'/2,
|
||||||
|
'create-lib'/2,
|
||||||
'create-node'/2,
|
'create-node'/2,
|
||||||
'list-templates'/2,
|
'list-templates'/2,
|
||||||
create/2]).
|
create/2]).
|
||||||
|
@ -50,6 +51,10 @@
|
||||||
%% Alias for create w/ template=simpleapp
|
%% Alias for create w/ template=simpleapp
|
||||||
create1(Config, "simpleapp").
|
create1(Config, "simpleapp").
|
||||||
|
|
||||||
|
'create-lib'(Config, _File) ->
|
||||||
|
%% Alias for create w/ template=simplelib
|
||||||
|
create1(Config, "simplelib").
|
||||||
|
|
||||||
'create-node'(Config, _File) ->
|
'create-node'(Config, _File) ->
|
||||||
%% Alias for create w/ template=simplenode
|
%% Alias for create w/ template=simplenode
|
||||||
create1(Config, "simplenode").
|
create1(Config, "simplenode").
|
||||||
|
@ -116,6 +121,12 @@ info(help, 'create-app') ->
|
||||||
"~n"
|
"~n"
|
||||||
"Valid command line options:~n"
|
"Valid command line options:~n"
|
||||||
" [appid=myapp]~n", []);
|
" [appid=myapp]~n", []);
|
||||||
|
info(help, 'create-lib') ->
|
||||||
|
?CONSOLE(
|
||||||
|
"Create simple lib skel.~n"
|
||||||
|
"~n"
|
||||||
|
"Valid command line options:~n"
|
||||||
|
" [libid=mylib]~n", []);
|
||||||
info(help, 'create-node') ->
|
info(help, 'create-node') ->
|
||||||
?CONSOLE(
|
?CONSOLE(
|
||||||
"Create simple node skel.~n"
|
"Create simple node skel.~n"
|
||||||
|
|
Loading…
Reference in a new issue