1 %% -*- mode: Erlang; fill-column: 80; comment-column: 75; -*-
2 %%%---------------------------------------------------------------------------
3 %%% @author Eric Merritt
5 %%% Return the sinan server version.
7 %%% @copyright (C) 2008-2011 Erlware
8 %%%---------------------------------------------------------------------------
9 -module(sin_task_version
).
13 -include_lib("sinan/include/sinan.hrl").
16 -export([description
/0, do_task
/2]).
18 -define(TASK
, version
).
21 %%====================================================================
23 %%====================================================================
24 %% @doc provides a description for this task
25 -spec
description() -> sin_task:task_description().
32 This command simply prents out the current version of sinan",
39 short_desc
= "Provides sinan version information",
43 %% @doc Get the version of sinan that is currently running
44 -spec
do_task(sin_config:config(), sin_state:state()) -> sin_state:state().
45 do_task(Config
, State
) ->
46 Version
= case get_version() of
52 sin_log:normal(Config
, "~s", [Version
]),
53 sin_state:store(sinan_vsn
, Version
, State
).
55 %%====================================================================
56 %%% Internal functions
57 %%====================================================================
59 %% @doc Gets the current version of the sinan release.
60 -spec
get_version() -> Vsn::string() | unkown_version
.
62 SinDir
= filename:join([filename:dirname(code:priv_dir(sinan
)), "ebin", "sinan.app"]),
63 get_version(file:consult(SinDir
)).
65 get_version({ok
, [{application
, sinan
, Opts
}]}) ->
66 case lists:keysearch(vsn
, 1, Opts
) of
67 {value
, {vsn
, Vsn
}} ->