summaryrefslogtreecommitdiff
path: root/priv/templates
diff options
context:
space:
mode:
Diffstat (limited to 'priv/templates')
-rw-r--r--priv/templates/LICENSE.dtl2
-rw-r--r--priv/templates/README.md.dtl4
-rw-r--r--priv/templates/app.erl.dtl6
-rw-r--r--priv/templates/app.template11
-rw-r--r--priv/templates/gitignore.dtl6
-rw-r--r--priv/templates/lib.template11
-rw-r--r--priv/templates/mod.erl.dtl6
-rw-r--r--priv/templates/otp_app.app.src.dtl7
-rw-r--r--priv/templates/otp_app.template7
-rw-r--r--priv/templates/otp_lib.app.src.dtl9
-rw-r--r--priv/templates/otp_lib.template7
-rw-r--r--priv/templates/otp_rel.template11
-rw-r--r--priv/templates/plugin.erl.dtl43
-rw-r--r--priv/templates/plugin.template18
-rw-r--r--priv/templates/plugin_README.md.dtl19
-rw-r--r--priv/templates/release.template15
-rw-r--r--priv/templates/relx.config.dtl4
-rw-r--r--priv/templates/sup.erl.dtl4
-rw-r--r--priv/templates/sys.config.dtl2
-rw-r--r--priv/templates/vm.args.dtl4
20 files changed, 116 insertions, 80 deletions
diff --git a/priv/templates/LICENSE.dtl b/priv/templates/LICENSE.dtl
index 5ce77ce..41588ab 100644
--- a/priv/templates/LICENSE.dtl
+++ b/priv/templates/LICENSE.dtl
@@ -1,4 +1,4 @@
-Copyright (c) {{copyright_year}}, {{copyright_holder}} <{{author_email}}>.
+Copyright (c) {{copyright_year}}, {{author_name}} <{{author_email}}>.
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/priv/templates/README.md.dtl b/priv/templates/README.md.dtl
index b2435a8..5507536 100644
--- a/priv/templates/README.md.dtl
+++ b/priv/templates/README.md.dtl
@@ -1,7 +1,7 @@
-{{appid}}
+{{name}}
=====
-An Erlang {{appid}} library.
+{{desc}}
Build
-----
diff --git a/priv/templates/app.erl.dtl b/priv/templates/app.erl.dtl
index 1c3e8f2..83eb9a3 100644
--- a/priv/templates/app.erl.dtl
+++ b/priv/templates/app.erl.dtl
@@ -1,9 +1,9 @@
%%%-------------------------------------------------------------------
-%% @doc {{appid}} public API
+%% @doc {{name}} public API
%% @end
%%%-------------------------------------------------------------------
--module({{appid}}_app).
+-module({{name}}_app).
-behaviour(application).
@@ -16,7 +16,7 @@
%%====================================================================
start(_StartType, _StartArgs) ->
- {{appid}}_sup:start_link().
+ {{name}}_sup:start_link().
%%--------------------------------------------------------------------
stop(_State) ->
diff --git a/priv/templates/app.template b/priv/templates/app.template
new file mode 100644
index 0000000..78374af
--- /dev/null
+++ b/priv/templates/app.template
@@ -0,0 +1,11 @@
+{description, "OTP Application"}.
+{variables, [
+ {name, "mylib", "Name of the OTP application"},
+ {desc, "An OTP application", "Short description of the app"}
+]}.
+{template, "app.erl.dtl", "src/{{name}}_app.erl"}.
+{template, "otp_app.app.src.dtl", "src/{{name}}.app.src"}.
+{template, "rebar.config.dtl", "rebar.config"}.
+{template, "gitignore.dtl", ".gitignore"}.
+{template, "LICENSE.dtl", "LICENSE"}.
+{template, "README.md.dtl", "README.md"}.
diff --git a/priv/templates/gitignore.dtl b/priv/templates/gitignore.dtl
index 23123d4..9e09bf1 100644
--- a/priv/templates/gitignore.dtl
+++ b/priv/templates/gitignore.dtl
@@ -1,13 +1,17 @@
_*
.eunit
-deps
*.o
*.beam
*.plt
+*.swp
+*.swo
.erlang.cookie
ebin
log
erl_crash.dump
.rebar
_rel
+_deps
+_plugins
+_tdeps
logs
diff --git a/priv/templates/lib.template b/priv/templates/lib.template
new file mode 100644
index 0000000..1db3b07
--- /dev/null
+++ b/priv/templates/lib.template
@@ -0,0 +1,11 @@
+{description, "OTP Library application (no processes)"}.
+{variables, [
+ {name, "mylib", "Name of the OTP library application"},
+ {desc, "An OTP library", "Short description of the app"}
+]}.
+{template, "mod.erl.dtl", "src/{{name}}.erl"}.
+{template, "otp_lib.app.src.dtl", "src/{{name}}.app.src"}.
+{template, "rebar.config.dtl", "rebar.config"}.
+{template, "gitignore.dtl", ".gitignore"}.
+{template, "LICENSE.dtl", "LICENSE"}.
+{template, "README.md.dtl", "README.md"}.
diff --git a/priv/templates/mod.erl.dtl b/priv/templates/mod.erl.dtl
index 1be8186..2f5e09e 100644
--- a/priv/templates/mod.erl.dtl
+++ b/priv/templates/mod.erl.dtl
@@ -1,10 +1,10 @@
--module({{appid}}).
+-module({{name}}).
-%% Application callbacks
+%% API exports
-export([]).
%%====================================================================
-%% API
+%% API functions
%%====================================================================
diff --git a/priv/templates/otp_app.app.src.dtl b/priv/templates/otp_app.app.src.dtl
index 0af909f..5188f56 100644
--- a/priv/templates/otp_app.app.src.dtl
+++ b/priv/templates/otp_app.app.src.dtl
@@ -1,9 +1,8 @@
-{application, {{appid}},
- [
- {description, "{{appid}}"}
+{application, {{name}},
+ [{description, "{{desc}}"}
,{vsn, "0.1.0"}
,{registered, []}
- ,{mod, {'{{appid}}_app', []}}
+ ,{mod, {'{{name}}_app', []}}
,{applications,
[kernel
,stdlib
diff --git a/priv/templates/otp_app.template b/priv/templates/otp_app.template
deleted file mode 100644
index db31b31..0000000
--- a/priv/templates/otp_app.template
+++ /dev/null
@@ -1,7 +0,0 @@
-{variables, []}.
-{template, "app.erl", "src/{{appid}}_app.erl"}.
-{template, "otp_app.app.src", "src/{{appid}}.app.src"}.
-{template, "rebar.config", "rebar.config"}.
-{template, "gitignore", ".gitignore"}.
-{template, "LICENSE", "LICENSE"}.
-{template, "README.md", "README.md"}.
diff --git a/priv/templates/otp_lib.app.src.dtl b/priv/templates/otp_lib.app.src.dtl
index 5192af7..3adefeb 100644
--- a/priv/templates/otp_lib.app.src.dtl
+++ b/priv/templates/otp_lib.app.src.dtl
@@ -1,12 +1,9 @@
-{application, {{appid}},
- [
- {description, "{{appid}}"}
+{application, {{name}},
+ [{description, "{{desc}}"}
,{vsn, "0.1.0"}
,{registered, []}
,{applications,
- [kernel
- ,stdlib
- ]}
+ [kernel,stdlib]}
,{env,[]}
,{modules, []}
]}.
diff --git a/priv/templates/otp_lib.template b/priv/templates/otp_lib.template
deleted file mode 100644
index 19d7593..0000000
--- a/priv/templates/otp_lib.template
+++ /dev/null
@@ -1,7 +0,0 @@
-{variables, []}.
-{template, "mod.erl", "src/{{appid}}.erl"}.
-{template, "otp_lib.app.src", "src/{{appid}}.app.src"}.
-{template, "rebar.config", "rebar.config"}.
-{template, "gitignore", ".gitignore"}.
-{template, "LICENSE", "LICENSE"}.
-{template, "README.md", "README.md"}.
diff --git a/priv/templates/otp_rel.template b/priv/templates/otp_rel.template
deleted file mode 100644
index b75c1da..0000000
--- a/priv/templates/otp_rel.template
+++ /dev/null
@@ -1,11 +0,0 @@
-{variables, []}.
-{template, "app.erl", "apps/{{appid}}/src/{{appid}}_app.erl"}.
-{template, "sup.erl", "apps/{{appid}}/src/{{appid}}_sup.erl"}.
-{template, "otp_app.app.src", "apps/{{appid}}/src/{{appid}}.app.src"}.
-{template, "rebar.config", "rebar.config"}.
-{template, "relx.config", "relx.config"}.
-{template, "sys.config", "config/sys.config"}.
-{template, "vm.args", "config/vm.args"}.
-{template, "gitignore", ".gitignore"}.
-{template, "LICENSE", "LICENSE"}.
-{template, "README.md", "README.md"}.
diff --git a/priv/templates/plugin.erl.dtl b/priv/templates/plugin.erl.dtl
index 80a03bb..df92cf6 100644
--- a/priv/templates/plugin.erl.dtl
+++ b/priv/templates/plugin.erl.dtl
@@ -1,29 +1,36 @@
--module({{appid}}).
+-module({{name}}).
+-behaviour(provider).
--behaviour(rebar_provider).
+-export([init/1, do/1, format_error/2]).
--export([init/1,
- do/1]).
+-include_lib("rebar3/include/rebar.hrl").
--define(PROVIDER, {{appid}}).
--define(DEPS, []).
+-define(PROVIDER, todo).
+-define(DEPS, [app_discovery]).
%% ===================================================================
%% Public API
%% ===================================================================
-
-spec init(rebar_state:t()) -> {ok, rebar_state:t()}.
init(State) ->
- State1 = rebar_state:add_provider(State, rebar_provider:create([{name, ?PROVIDER},
- {provider_impl, ?MODULE},
- {bare, false},
- {deps, ?DEPS},
- {example, "rebar {{appid}}"},
- {short_desc, "{{appid}} plugin."},
- {desc, ""},
- {opts, []}])),
- {ok, State1}.
-
--spec do(rebar_state:t()) -> {ok, rebar_state:t()}.
+ Provider = providers:create([
+ {name, ?PROVIDER}, % The 'user friendly' name of the task
+ {module, ?MODULE}, % The module implementation of the task
+ {bare, true}, % The task can be run by the user, always true
+ {deps, ?DEPS}, % The list of dependencies
+ {example, "rebar {{name}}"}, % How to use the plugin
+ {opts, []} % list of options understood by the plugin
+ {short_desc, {{desc}}},
+ {desc, ""}
+ ]),
+ {ok, rebar_state:add_provider(State, Provider)}.
+
+
+-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
do(State) ->
{ok, State}.
+
+-spec format_error(any(), rebar_state:t()) -> {iolist(), rebar_state:t()}.
+format_error(Reason, State) ->
+ {io_lib:format("~p", [Reason]), State}.
+
diff --git a/priv/templates/plugin.template b/priv/templates/plugin.template
index bc44863..a7e15cc 100644
--- a/priv/templates/plugin.template
+++ b/priv/templates/plugin.template
@@ -1,7 +1,11 @@
-{variables, []}.
-{template, "plugin.erl", "src/{{appid}}.erl"}.
-{template, "otp_lib.app.src", "src/{{appid}}.app.src"}.
-{template, "rebar.config", "rebar.config"}.
-{template, "gitignore", ".gitignore"}.
-{template, "LICENSE", "LICENSE"}.
-{template, "plugin_README.md", "README.md"}.
+{description, "Rebar3 plugin"}.
+{variables, [
+ {name, "myplugin", "Name of the plugin"},
+ {desc, "A rebar plugin", "Short description of the plugin's purpose"}
+]}.
+{template, "plugin.erl.dtl", "src/{{name}}.erl"}.
+{template, "otp_lib.app.src.dtl", "src/{{name}}.app.src"}.
+{template, "rebar.config.dtl", "rebar.config"}.
+{template, "gitignore.dtl", ".gitignore"}.
+{template, "LICENSE.dtl", "LICENSE"}.
+{template, "plugin_README.md.dtl", "README.md"}.
diff --git a/priv/templates/plugin_README.md.dtl b/priv/templates/plugin_README.md.dtl
index 19990f5..8c91947 100644
--- a/priv/templates/plugin_README.md.dtl
+++ b/priv/templates/plugin_README.md.dtl
@@ -1,7 +1,7 @@
-{{appid}}
+{{name}}
=====
-Rebar3 plugin
+{{desc}}
Build
-----
@@ -11,4 +11,17 @@ Build
Use
---
- $ rebar3 {{appid}}
+Add the plugin to your rebar config:
+
+ {plugins, [
+ { {{name}}, ".*", {git, "git@host:user/{{name}}.git", {tag, "0.1.0"}}}
+ ]}.
+
+Then just call your plugin directly in an existing application:
+
+
+ $ rebar3 {{name}}
+ ===> Fetching {{name}}
+ Cloning into '.tmp_dir539136867963'...
+ ===> Compiling {{name}}
+ <Plugin Output>
diff --git a/priv/templates/release.template b/priv/templates/release.template
new file mode 100644
index 0000000..3539392
--- /dev/null
+++ b/priv/templates/release.template
@@ -0,0 +1,15 @@
+{description, "OTP Release structure for executable programs"}.
+{variables, [
+ {name, "myapp", "Name of the OTP release. An app with this name will also be created."},
+ {desc, "An OTP application", "Short description of the release's main app's purpose"}
+]}.
+{template, "app.erl.dtl", "{{apps_dir}}/{{name}}/src/{{name}}_app.erl"}.
+{template, "sup.erl.dtl", "{{apps_dir}}/{{name}}/src/{{name}}_sup.erl"}.
+{template, "otp_app.app.src.dtl", "{{apps_dir}}/{{name}}/src/{{name}}.app.src"}.
+{template, "rebar.config.dtl", "rebar.config"}.
+{template, "relx.config.dtl", "relx.config"}.
+{template, "sys.config.dtl", "config/sys.config"}.
+{template, "vm.args.dtl", "config/vm.args"}.
+{template, "gitignore.dtl", ".gitignore"}.
+{template, "LICENSE.dtl", "LICENSE"}.
+{template, "README.md.dtl", "README.md"}.
diff --git a/priv/templates/relx.config.dtl b/priv/templates/relx.config.dtl
index 7cb3a8a..7b08f97 100644
--- a/priv/templates/relx.config.dtl
+++ b/priv/templates/relx.config.dtl
@@ -1,6 +1,6 @@
%% -*- mode: Erlang; fill-column: 80; comment-column: 75; -*-
-{release, {'{{appid}}', "0.1.0"},
- [{{appid}},
+{release, {'{{name}}', "0.1.0"},
+ [{{name}},
sasl]}.
{sys_config, "./config/sys.config"}.
diff --git a/priv/templates/sup.erl.dtl b/priv/templates/sup.erl.dtl
index 3dd5b12..a2e7209 100644
--- a/priv/templates/sup.erl.dtl
+++ b/priv/templates/sup.erl.dtl
@@ -1,9 +1,9 @@
%%%-------------------------------------------------------------------
-%% @doc {{appid}} top level supervisor.
+%% @doc {{name}} top level supervisor.
%% @end
%%%-------------------------------------------------------------------
--module({{appid}}_sup).
+-module({{name}}_sup).
-behaviour(supervisor).
diff --git a/priv/templates/sys.config.dtl b/priv/templates/sys.config.dtl
index e678cf7..7fd6bcb 100644
--- a/priv/templates/sys.config.dtl
+++ b/priv/templates/sys.config.dtl
@@ -1,3 +1,3 @@
[
- {'{{appid}}', []}
+ {'{{name}}', []}
].
diff --git a/priv/templates/vm.args.dtl b/priv/templates/vm.args.dtl
index 27028ac..a8a43f0 100644
--- a/priv/templates/vm.args.dtl
+++ b/priv/templates/vm.args.dtl
@@ -1,6 +1,6 @@
--name {{appid}}
+-name {{name}}
--setcookie {{appid}}_cookie
+-setcookie {{name}}_cookie
+K true
+A30