From 8f1bfcb5965c3647d16f3c2fe596fc35d1f94e09 Mon Sep 17 00:00:00 2001 From: Fred Hebert Date: Mon, 13 Apr 2015 17:09:57 +0000 Subject: Rename wtf->report, add all dep versions --- src/rebar.app.src | 2 +- src/rebar3.erl | 4 +- src/rebar_prv_report.erl | 104 +++++++++++++++++++++++++++++++++++++++++++++++ src/rebar_prv_wtf.erl | 100 --------------------------------------------- 4 files changed, 107 insertions(+), 103 deletions(-) create mode 100644 src/rebar_prv_report.erl delete mode 100644 src/rebar_prv_wtf.erl diff --git a/src/rebar.app.src b/src/rebar.app.src index 0fd3579..61f719b 100644 --- a/src/rebar.app.src +++ b/src/rebar.app.src @@ -46,12 +46,12 @@ rebar_prv_new, rebar_prv_packages, rebar_prv_release, + rebar_prv_report, rebar_prv_shell, rebar_prv_tar, rebar_prv_update, rebar_prv_upgrade, rebar_prv_version, - rebar_prv_wtf, rebar_prv_xref]} ]} ]}. diff --git a/src/rebar3.erl b/src/rebar3.erl index 84eae05..460bc36 100644 --- a/src/rebar3.erl +++ b/src/rebar3.erl @@ -55,7 +55,7 @@ main(Args) -> non_existing -> ?ERROR("Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace", []), ?DEBUG("Uncaught error: ~p ~p", [Module, Reason]), - ?INFO("When submitting a bug report, please include the output of `rebar3 wtf \"your command\"`", []); + ?INFO("When submitting a bug report, please include the output of `rebar3 report \"your command\"`", []); _ -> ?ERROR(Module:format_error(Reason), []) end, @@ -68,7 +68,7 @@ main(Args) -> %% Dump this error to console ?ERROR("Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace", []), ?DEBUG("Uncaught error: ~p", [Error]), - ?INFO("When submitting a bug report, please include the output of `rebar3 wtf \"your command\"`", []), + ?INFO("When submitting a bug report, please include the output of `rebar3 report \"your command\"`", []), erlang:halt(1) end. diff --git a/src/rebar_prv_report.erl b/src/rebar_prv_report.erl new file mode 100644 index 0000000..45bc0b0 --- /dev/null +++ b/src/rebar_prv_report.erl @@ -0,0 +1,104 @@ +%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*- +%% ex: ts=4 sw=4 et + +-module(rebar_prv_report). + +-behaviour(provider). + +-export([init/1, + do/1, + format_error/1]). + +-include("rebar.hrl"). + +-define(PROVIDER, report). +-define(DEPS, []). +-define(ISSUES_URL, "https://github.com/rebar/rebar3/issues"). + +%% =================================================================== +%% Public API +%% =================================================================== + +-spec init(rebar_state:t()) -> {ok, rebar_state:t()}. +init(State) -> + State1 = rebar_state:add_provider(State, providers:create([{name, ?PROVIDER}, + {module, ?MODULE}, + {bare, false}, + {deps, ?DEPS}, + {example, "rebar3 report \"\""}, + {short_desc, "Provide a crash report to be sent to the rebar3 issues page."}, + {desc, "Provide a crash report to be sent to the rebar3 issues page."}, + {opts, [ + {task, undefined, undefined, string, "Task to print details for."} + ]}])), + {ok, State1}. + +-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}. +do(State) -> + %% Show command + Task = rebar_state:command_args(State), + Command = parse_task(Task), + %% Show command version (if a plugin?) + %% ... + %% Show app versions (including rebar3) + {ok, Vsn} = application:get_key(rebar, vsn), + {ok, Apps} = application:get_key(rebar, applications), + [application:ensure_started(App) || App <- Apps], + Vsns = [io_lib:format("~p: ~s~n", [App, AVsn]) + || App <- lists:sort(Apps), + {ok, AVsn} <- [application:get_key(App, vsn)]], + %% Show OS and versions + OS = erlang:system_info(system_architecture), + %% Erlang version (ERTS) + ERTS = erlang:system_info(system_version), + %% ERTS root directory + Root = code:root_dir(), + Lib = code:lib_dir(), + %% datetime + UTC = calendar:universal_time(), + %% + ?CONSOLE( + "Rebar3 report~n" + " version ~s~n" + " generated at ~s~n" + "=================~n" + "Please submit this along with your issue at ~s " + "(and feel free to edit out private information, if any)~n" + "-----------------~n" + "Task: ~ts~n" + "Entered as:~n" + " ~ts~n" + "-----------------~n" + "Operating System: ~ts~n" + "ERTS: ~ts" + "Root Directory: ~ts~n" + "Library directory: ~ts~n" + "-----------------~n" + "Loaded Applications:~n" + "~s~n" + "-----------------~n" + "Escript path: ~ts~n" + "Providers:~n" + " ~s", + [Vsn, time_to_string(UTC), + ?ISSUES_URL, Command, Task, + OS, ERTS, Root, Lib, + Vsns, + rebar_state:escript_path(State), + [providers:format(P)++" " + || P <- lists:sort(rebar_state:providers(State))] + ] + ), + {ok, State}. + +-spec format_error(any()) -> iolist(). +format_error(Reason) -> + io_lib:format("~p", [Reason]). + +time_to_string({{Y,M,D},{H,Min,S}}) -> + lists:flatten(io_lib:format("~4..0w-~2..0w-~2..0wT~2..0w:~2..0w:~2..0w+00:00", + [Y,M,D,H,Min,S])). + +parse_task(Str) -> + hd(re:split(Str, " ")). + diff --git a/src/rebar_prv_wtf.erl b/src/rebar_prv_wtf.erl deleted file mode 100644 index 9be9a4b..0000000 --- a/src/rebar_prv_wtf.erl +++ /dev/null @@ -1,100 +0,0 @@ -%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*- -%% ex: ts=4 sw=4 et - --module(rebar_prv_wtf). - --behaviour(provider). - --export([init/1, - do/1, - format_error/1]). - --include("rebar.hrl"). - --define(PROVIDER, wtf). --define(DEPS, []). --define(ISSUES_URL, "https://github.com/rebar/rebar3/issues"). - -%% =================================================================== -%% Public API -%% =================================================================== - --spec init(rebar_state:t()) -> {ok, rebar_state:t()}. -init(State) -> - State1 = rebar_state:add_provider(State, providers:create([{name, ?PROVIDER}, - {module, ?MODULE}, - {bare, false}, - {deps, ?DEPS}, - {example, "rebar3 wtf \"\""}, - {short_desc, "Provide a crash report to be sent to the rebar3 issues page."}, - {desc, "Provide a crash report to be sent to the rebar3 issues page."}, - {opts, [ - {task, undefined, undefined, string, "Task to print details for."} - ]}])), - {ok, State1}. - --spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}. -do(State) -> - %% Show command - Task = rebar_state:command_args(State), - Command = parse_task(Task), - %% Show command version (if a plugin?) - %% ... - %% Show app versions (including rebar3) - {ok, Vsn} = application:get_key(rebar, vsn), - Vsns = application:which_applications(), - %% Show OS and versions - OS = erlang:system_info(system_architecture), - %% Erlang version (ERTS) - ERTS = erlang:system_info(system_version), - %% ERTS root directory - Root = code:root_dir(), - Lib = code:lib_dir(), - %% datetime - UTC = calendar:universal_time(), - %% - ?CONSOLE( - "Rebar3 wtf report~n" - " version ~s~n" - " generated at ~s~n" - "=================~n" - "Please submit this along with your issue at ~s " - "(and feel free to edit out private information, if any)~n" - "-----------------~n" - "Task: ~ts~n" - "Entered as:~n" - " ~ts~n" - "-----------------~n" - "Operating System: ~ts~n" - "ERTS: ~ts" - "Root Directory: ~ts~n" - "Library directory: ~ts~n" - "-----------------~n" - "Loaded Applications:~n" - "~p~n" - "-----------------~n" - "Escript path: ~ts~n" - "Providers:~n" - " ~s", - [Vsn, time_to_string(UTC), - ?ISSUES_URL, Command, Task, - OS, ERTS, Root, Lib, - Vsns, - rebar_state:escript_path(State), - [providers:format(P)++" " - || P <- lists:sort(rebar_state:providers(State))] - ] - ), - {ok, State}. - --spec format_error(any()) -> iolist(). -format_error(Reason) -> - io_lib:format("~p", [Reason]). - -time_to_string({{Y,M,D},{H,Min,S}}) -> - lists:flatten(io_lib:format("~4..0w-~2..0w-~2..0wT~2..0w:~2..0w:~2..0w+00:00", - [Y,M,D,H,Min,S])). - -parse_task(Str) -> - hd(re:split(Str, " ")). - -- cgit v1.1 From 6acf0ea482bdf82813d31ca3eda558eea8903d9d Mon Sep 17 00:00:00 2001 From: Fred Hebert Date: Mon, 13 Apr 2015 17:42:21 +0000 Subject: Add in shell completion for wtf->report rename --- priv/shell-completion/bash/rebar3 | 6 +++--- priv/shell-completion/zsh/_rebar3 | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/priv/shell-completion/bash/rebar3 b/priv/shell-completion/bash/rebar3 index 758deee..cb6f69d 100644 --- a/priv/shell-completion/bash/rebar3 +++ b/priv/shell-completion/bash/rebar3 @@ -24,12 +24,12 @@ _rebar3() new \ pkgs \ release \ + report \ shell \ tar \ update \ upgrade \ version \ - wtf \ xref" elif [[ ${prev} == as ]] ; then : @@ -115,6 +115,8 @@ _rebar3() --system_libs \ --version \ --root" + elif [[ ${prev} == report ]] ; then + : elif [[ ${prev} == shell ]] ; then : elif [[ ${prev} == tar ]] ; then @@ -145,8 +147,6 @@ _rebar3() : elif [[ ${prev} == version ]] ; then : - elif [[ ${prev} == wtf ]] ; then - : elif [[ ${prev} == xref ]] ; then : fi diff --git a/priv/shell-completion/zsh/_rebar3 b/priv/shell-completion/zsh/_rebar3 index 347451b..6950688 100644 --- a/priv/shell-completion/zsh/_rebar3 +++ b/priv/shell-completion/zsh/_rebar3 @@ -131,6 +131,9 @@ _rebar3 () { '(-r --root)'{-r,--root}'[The project root directory]:system libs:_files -/' \ && ret=0 ;; + (report) + _arguments '1: :_rebar3_tasks' && ret=0 + ;; (shell) _message 'Start a shell with project and deps preloaded' && ret=0 ;; @@ -168,9 +171,6 @@ _rebar3 () { (version) _message 'rebar version' && ret=0 ;; - (wtf) - _arguments '1: :_rebar3_tasks' && ret=0 - ;; (xref) _message 'rebar xref' && ret=0 esac @@ -194,12 +194,12 @@ _rebar3_tasks() { 'new:Create new project from templates.' 'pkgs:List available packages.' 'release:Build release of project.' + 'report:Provide a crash report to be sent to the rebar3 issues page.' 'shell:Run shell with project apps and deps in path.' 'tar:Tar archive of release built of project.' 'update:Update package index.' 'upgrade:Upgrade dependencies.' 'version:Print version for rebar and current Erlang.' - 'wtf:Provide a crash report to be sent to the rebar3 issues page.' 'xref:Run cross reference analysis.' ) _describe -t tasks 'rebar3 tasks' tasks "$@" -- cgit v1.1