Ver. 2.6.0
This commit is contained in:
parent
b29a014600
commit
48af4311e1
|
@ -2,3 +2,4 @@
|
|||
/basho-rebar-RELEASE-1-821-g635d1a9.tar.gz
|
||||
/basho-rebar-2.0.0-0-g1c98f6c.tar.gz
|
||||
/basho-rebar-2.1.0-pre-0-gebb474b.tar.gz
|
||||
/rebar-5dea85db1b697466586877bed133748bd80fa180.tar.gz
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
%global realname rebar
|
||||
%global upstream basho
|
||||
%global debug_package %{nil}
|
||||
%global git_tag ebb474b
|
||||
%global commit 5dea85db1b697466586877bed133748bd80fa180
|
||||
%global patchnumber 0
|
||||
|
||||
# Set this to true when starting a rebuild of the whole erlang stack. There's
|
||||
|
@ -13,45 +13,38 @@
|
|||
|
||||
|
||||
Name: erlang-%{realname}
|
||||
Version: 2.1.0
|
||||
Release: 0.10%{?dist}
|
||||
Version: 2.6.0
|
||||
Release: 1%{?dist}
|
||||
Summary: Erlang Build Tools
|
||||
Group: Development/Tools
|
||||
License: MIT
|
||||
URL: https://github.com/rebar/rebar
|
||||
# wget --content-disposition https://github.com/basho/rebar/tarball/ebb474b
|
||||
Source0: %{upstream}-%{realname}-%{version}-pre-%{patchnumber}-g%{git_tag}.tar.gz
|
||||
# wget --content-disposition https://github.com/rebar/rebar/archive/5dea85db1b697466586877bed133748bd80fa180/rebar-5dea85db1b697466586877bed133748bd80fa180.tar.gz
|
||||
Source0: https://github.com/rebar/rebar/archive/%{commit}/%{realname}-%{commit}.tar.gz
|
||||
Source1: rebar.escript
|
||||
# Fedora/EPEL-specific
|
||||
Patch1: rebar-0001-Don-t-load-templates-from-the-bundle.patch
|
||||
# Fedora/EPEL-specific
|
||||
Patch2: rebar-0002-Remove-bundled-mustache.patch
|
||||
|
||||
# The bundled getopt is necessary to do the initial bootstrap since
|
||||
# erlang-getopt requires erlang-rebar to build and vice versa.
|
||||
%if 0%{?need_bootstrap} < 1
|
||||
# Fedora/EPEL-specific
|
||||
Patch3: rebar-0003-Remove-bundled-getopt.patch
|
||||
%endif
|
||||
# Backported from upstream
|
||||
Patch4: rebar-0004-Be-sure-to-filter-empty-sources-h-t-to-Tuncer-and-Jo.patch
|
||||
# Will be proposed for inclusion
|
||||
Patch5: rebar-0005-Allow-discarding-building-ports.patch
|
||||
Patch4: rebar-0004-Allow-discarding-building-ports.patch
|
||||
# Fedora/EPEL-specific
|
||||
Patch6: rebar-0006-Check-system-wide-libdir-in-case-of-source-based-dep.patch
|
||||
Patch5: rebar-0005-Check-system-wide-libdir-in-case-of-source-based-dep.patch
|
||||
# Fedora/EPEL-specific
|
||||
Patch7: rebar-0007-Remove-any-traces-of-long-time-obsolete-escript-fold.patch
|
||||
Patch6: rebar-0006-Remove-any-traces-of-long-time-obsolete-escript-fold.patch
|
||||
# Fedora/EPEL-specific - unfortunately we don't have abnfc compiler available yet
|
||||
Patch8: rebar-0008-Remove-abnfc-compiler-support-n-a-in-Fedora-EPEL.patch
|
||||
# Fedora/EPEL-specific - cosmetic
|
||||
Patch9: rebar-0009-Adjust-app-version.patch
|
||||
# Backported from upstream
|
||||
Patch10: rebar-0010-Fix-default-DTL-compilation-when-no-erlydtl_opts-are.patch
|
||||
Patch7: rebar-0007-Remove-abnfc-compiler-support-n-a-in-Fedora-EPEL.patch
|
||||
|
||||
%if 0%{?need_bootstrap} < 1
|
||||
BuildRequires: erlang-rebar
|
||||
%else
|
||||
BuildRequires: erlang
|
||||
BuildRequires: erlang
|
||||
%endif
|
||||
|
||||
# FIXME wip
|
||||
|
@ -92,19 +85,16 @@ Erlang Build Tools.
|
|||
|
||||
|
||||
%prep
|
||||
%setup -q -n %{upstream}-%{realname}-%{git_tag}
|
||||
%setup -q -n %{realname}-%{commit}
|
||||
%patch1 -p1 -b .dont_load_templates
|
||||
%patch2 -p1 -b .remove_bundled_mustache
|
||||
%if 0%{?need_bootstrap} < 1
|
||||
%patch3 -p1 -b .remove_bundled_getopt
|
||||
%endif
|
||||
%patch4 -p1 -b .dont_try_building_so
|
||||
%patch5 -p1 -b .allow_discarding_ports
|
||||
%patch6 -p1 -b .use_locally_installed
|
||||
%patch7 -p1 -b .remove_escript_foldl_3
|
||||
%patch8 -p1 -b .no_abnfc
|
||||
%patch9 -p1 -b .adjust_ver
|
||||
%patch10 -p1 -b .fix_dtl
|
||||
%patch4 -p1 -b .allow_discarding_ports
|
||||
%patch5 -p1 -b .use_locally_installed
|
||||
%patch6 -p1 -b .remove_escript_foldl_3
|
||||
%patch7 -p1 -b .no_abnfc
|
||||
|
||||
|
||||
%build
|
||||
|
@ -131,12 +121,16 @@ cp -a priv %{buildroot}%{_libdir}/erlang/lib/%{realname}-%{version}/
|
|||
|
||||
|
||||
%files
|
||||
%doc LICENSE NOTES.org README.md THANKS rebar.config.sample
|
||||
%doc README.md THANKS rebar.config.sample
|
||||
%license LICENSE
|
||||
%{_bindir}/rebar
|
||||
%{_libdir}/erlang/lib/%{realname}-%{version}
|
||||
|
||||
|
||||
%changelog
|
||||
* Fri Jul 03 2015 Filip Andres <filip@andresovi.net> - 2.6.0-1
|
||||
- Update to 2.6.0
|
||||
|
||||
* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.1.0-0.10
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
|
||||
|
||||
|
|
|
@ -1,35 +1,34 @@
|
|||
From fce5d859e5a24dcbff1796293a4835078b758080 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Lemenkov <lemenkov@gmail.com>
|
||||
Date: Sat, 20 Nov 2010 16:36:45 +0300
|
||||
Subject: [PATCH 02/10] Remove bundled mustache
|
||||
From 119d6edc55c673d88b97e18aeb97ce1dcfb207c4 Mon Sep 17 00:00:00 2001
|
||||
From: Filip Andres <filip@andresovi.net>
|
||||
Date: Fri, 3 Jul 2015 10:46:48 +0200
|
||||
Subject: [PATCH] Remove bundled mustache
|
||||
|
||||
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
|
||||
---
|
||||
ebin/rebar.app | 3 +-
|
||||
src/mustache.erl | 228 -------------------------------------------------------
|
||||
2 files changed, 1 insertion(+), 230 deletions(-)
|
||||
delete mode 100644 src/mustache.erl
|
||||
ebin/rebar.app | 1 -
|
||||
src/rebar_mustache.erl | 230 ----------------------------
|
||||
src/rebar_templater.erl | 2 +-
|
||||
src/rebar_templater.erl.dont_load_templates | 2 +-
|
||||
4 files changed, 2 insertions(+), 233 deletions(-)
|
||||
delete mode 100644 src/rebar_mustache.erl
|
||||
|
||||
diff --git a/ebin/rebar.app b/ebin/rebar.app
|
||||
index 8df929f..9e000fa 100644
|
||||
index 152829d..967afb0 100644
|
||||
--- a/ebin/rebar.app
|
||||
+++ b/ebin/rebar.app
|
||||
@@ -37,8 +37,7 @@
|
||||
rebar_upgrade,
|
||||
rebar_utils,
|
||||
@@ -45,7 +45,6 @@
|
||||
rebar_xref,
|
||||
- getopt,
|
||||
- mustache ]},
|
||||
+ getopt ]},
|
||||
rebar_metacmds,
|
||||
rebar_getopt,
|
||||
- rebar_mustache,
|
||||
rmemo ]},
|
||||
{registered, []},
|
||||
{applications, [kernel,
|
||||
stdlib,
|
||||
diff --git a/src/mustache.erl b/src/mustache.erl
|
||||
{applications,
|
||||
diff --git a/src/rebar_mustache.erl b/src/rebar_mustache.erl
|
||||
deleted file mode 100644
|
||||
index f6963cd..0000000
|
||||
--- a/src/mustache.erl
|
||||
index 9016c0f..0000000
|
||||
--- a/src/rebar_mustache.erl
|
||||
+++ /dev/null
|
||||
@@ -1,228 +0,0 @@
|
||||
@@ -1,230 +0,0 @@
|
||||
-%% The MIT License
|
||||
-%%
|
||||
-%% Copyright (c) 2009 Tom Preston-Werner <tom@mojombo.com>
|
||||
|
@ -55,7 +54,7 @@ index f6963cd..0000000
|
|||
-%% See the README at http://github.com/mojombo/mustache.erl for additional
|
||||
-%% documentation and usage examples.
|
||||
-
|
||||
--module(mustache). %% v0.1.0
|
||||
--module(rebar_mustache). %% v0.1.0
|
||||
--author("Tom Preston-Werner").
|
||||
--export([compile/1, compile/2, render/1, render/2, render/3, get/2, get/3, escape/1, start/1]).
|
||||
-
|
||||
|
@ -63,6 +62,8 @@ index f6963cd..0000000
|
|||
- section_re = undefined,
|
||||
- tag_re = undefined}).
|
||||
-
|
||||
--define(MUSTACHE_STR, "rebar_mustache").
|
||||
-
|
||||
-compile(Body) when is_list(Body) ->
|
||||
- State = #mstate{},
|
||||
- CompiledTemplate = pre_compile(Body, State),
|
||||
|
@ -140,7 +141,7 @@ index f6963cd..0000000
|
|||
- Mod = State#mstate.mod,
|
||||
- Result = compiler(Content, State),
|
||||
- "fun() -> " ++
|
||||
- "case mustache:get(" ++ Name ++ ", Ctx, " ++ atom_to_list(Mod) ++ ") of " ++
|
||||
- "case " ++ ?MUSTACHE_STR ++ ":get(" ++ Name ++ ", Ctx, " ++ atom_to_list(Mod) ++ ") of " ++
|
||||
- "\"true\" -> " ++
|
||||
- Result ++ "; " ++
|
||||
- "\"false\" -> " ++
|
||||
|
@ -175,10 +176,10 @@ index f6963cd..0000000
|
|||
-
|
||||
-compile_tag(none, Content, State) ->
|
||||
- Mod = State#mstate.mod,
|
||||
- "mustache:escape(mustache:get(" ++ Content ++ ", Ctx, " ++ atom_to_list(Mod) ++ "))";
|
||||
- ?MUSTACHE_STR ++ ":escape(" ++ ?MUSTACHE_STR ++ ":get(" ++ Content ++ ", Ctx, " ++ atom_to_list(Mod) ++ "))";
|
||||
-compile_tag("{", Content, State) ->
|
||||
- Mod = State#mstate.mod,
|
||||
- "mustache:get(" ++ Content ++ ", Ctx, " ++ atom_to_list(Mod) ++ ")";
|
||||
- ?MUSTACHE_STR ++ ":get(" ++ Content ++ ", Ctx, " ++ atom_to_list(Mod) ++ ")";
|
||||
-compile_tag("!", _Content, _State) ->
|
||||
- "[]".
|
||||
-
|
||||
|
@ -258,6 +259,32 @@ index f6963cd..0000000
|
|||
-start([T]) ->
|
||||
- Out = render(list_to_atom(T)),
|
||||
- io:format(Out ++ "~n", []).
|
||||
diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl
|
||||
index efee394..77c5bd8 100644
|
||||
--- a/src/rebar_templater.erl
|
||||
+++ b/src/rebar_templater.erl
|
||||
@@ -103,7 +103,7 @@ render(Bin, Context) ->
|
||||
ReOpts = [global, {return, list}],
|
||||
Str0 = re:replace(Bin, "\\\\", "\\\\\\", ReOpts),
|
||||
Str1 = re:replace(Str0, "\"", "\\\\\"", ReOpts),
|
||||
- rebar_mustache:render(Str1, Context).
|
||||
+ mustache:render(Str1, Context).
|
||||
|
||||
%% ===================================================================
|
||||
%% Internal functions
|
||||
diff --git a/src/rebar_templater.erl.dont_load_templates b/src/rebar_templater.erl.dont_load_templates
|
||||
index 085ac1c..0b70976 100644
|
||||
--- a/src/rebar_templater.erl.dont_load_templates
|
||||
+++ b/src/rebar_templater.erl.dont_load_templates
|
||||
@@ -103,7 +103,7 @@ render(Bin, Context) ->
|
||||
ReOpts = [global, {return, list}],
|
||||
Str0 = re:replace(Bin, "\\\\", "\\\\\\", ReOpts),
|
||||
Str1 = re:replace(Str0, "\"", "\\\\\"", ReOpts),
|
||||
- rebar_mustache:render(Str1, Context).
|
||||
+ mustache:render(Str1, Context).
|
||||
|
||||
%% ===================================================================
|
||||
%% Internal functions
|
||||
--
|
||||
1.8.1.4
|
||||
2.1.0
|
||||
|
||||
|
|
|
@ -1,35 +1,55 @@
|
|||
From e200556bfca9db7e496a50b62fa09a5f46f22b25 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Lemenkov <lemenkov@gmail.com>
|
||||
Date: Sat, 20 Nov 2010 16:40:15 +0300
|
||||
Subject: [PATCH 03/10] Remove bundled getopt
|
||||
From 42fac65535e6cc260e39cd7594ac7de28129f76b Mon Sep 17 00:00:00 2001
|
||||
From: Filip Andres <filip@andresovi.net>
|
||||
Date: Fri, 3 Jul 2015 10:56:26 +0200
|
||||
Subject: [PATCH] Remove bundled getopt
|
||||
|
||||
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
|
||||
---
|
||||
ebin/rebar.app | 3 +-
|
||||
src/getopt.erl | 621 ---------------------------------------------------------
|
||||
2 files changed, 1 insertion(+), 623 deletions(-)
|
||||
delete mode 100644 src/getopt.erl
|
||||
ebin/rebar.app | 1 -
|
||||
src/rebar.erl | 4 +-
|
||||
src/rebar_getopt.erl | 914 ---------------------------------------------------
|
||||
3 files changed, 2 insertions(+), 917 deletions(-)
|
||||
delete mode 100644 src/rebar_getopt.erl
|
||||
|
||||
diff --git a/ebin/rebar.app b/ebin/rebar.app
|
||||
index 9e000fa..cba8bf8 100644
|
||||
index 8a65fc8..2d2a0e7 100644
|
||||
--- a/ebin/rebar.app
|
||||
+++ b/ebin/rebar.app
|
||||
@@ -36,8 +36,7 @@
|
||||
rebar_templater,
|
||||
rebar_upgrade,
|
||||
@@ -43,7 +43,6 @@
|
||||
rebar_utils,
|
||||
- rebar_xref,
|
||||
- getopt ]},
|
||||
+ rebar_xref]},
|
||||
rebar_xref,
|
||||
rebar_metacmds,
|
||||
- rebar_getopt,
|
||||
rmemo ]},
|
||||
{registered, []},
|
||||
{applications, [kernel,
|
||||
stdlib,
|
||||
diff --git a/src/getopt.erl b/src/getopt.erl
|
||||
{applications,
|
||||
diff --git a/src/rebar.erl b/src/rebar.erl
|
||||
index dcfb353..2040e7a 100644
|
||||
--- a/src/rebar.erl
|
||||
+++ b/src/rebar.erl
|
||||
@@ -233,7 +233,7 @@ run_aux(BaseConfig, Commands) ->
|
||||
%%
|
||||
help() ->
|
||||
OptSpecList = option_spec_list(),
|
||||
- rebar_getopt:usage(OptSpecList, "rebar",
|
||||
+ getopt:usage(OptSpecList, "rebar",
|
||||
"[var=value,...] <command,...>",
|
||||
[{"var=value", "rebar global variables (e.g. force=1)"},
|
||||
{"command", "Command to run (e.g. compile)"}]),
|
||||
@@ -293,7 +293,7 @@ help() ->
|
||||
parse_args(RawArgs) ->
|
||||
%% Parse getopt options
|
||||
OptSpecList = option_spec_list(),
|
||||
- case rebar_getopt:parse(OptSpecList, RawArgs) of
|
||||
+ case getopt:parse(OptSpecList, RawArgs) of
|
||||
{ok, Args} ->
|
||||
Args;
|
||||
{error, {Reason, Data}} ->
|
||||
diff --git a/src/rebar_getopt.erl b/src/rebar_getopt.erl
|
||||
deleted file mode 100644
|
||||
index 175b7a5..0000000
|
||||
--- a/src/getopt.erl
|
||||
index 79b871d..0000000
|
||||
--- a/src/rebar_getopt.erl
|
||||
+++ /dev/null
|
||||
@@ -1,621 +0,0 @@
|
||||
@@ -1,914 +0,0 @@
|
||||
-%%%-------------------------------------------------------------------
|
||||
-%%% @author Juan Jose Comellas <juanjo@comellas.org>
|
||||
-%%% @copyright (C) 2009 Juan Jose Comellas
|
||||
|
@ -40,22 +60,15 @@ index 175b7a5..0000000
|
|||
-%%% a copy of the New BSD license with this software. If not, it can be
|
||||
-%%% retrieved from: http://www.opensource.org/licenses/bsd-license.php
|
||||
-%%%-------------------------------------------------------------------
|
||||
--module(getopt).
|
||||
--module(rebar_getopt).
|
||||
--author('juanjo@comellas.org').
|
||||
-
|
||||
--export([parse/2, usage/2, usage/3, usage/4]).
|
||||
--export([parse/2, check/2, parse_and_check/2, format_error/2,
|
||||
- usage/2, usage/3, usage/4, tokenize/1]).
|
||||
--export([usage_cmd_line/2]).
|
||||
-
|
||||
--export_type([arg_type/0,
|
||||
- arg_value/0,
|
||||
- arg_spec/0,
|
||||
- simple_option/0,
|
||||
- compound_option/0,
|
||||
- option/0,
|
||||
- option_spec/0]).
|
||||
-
|
||||
--define(TAB_LENGTH, 8).
|
||||
-%% Indentation of the help messages in number of tabs.
|
||||
--define(INDENTATION, 3).
|
||||
--define(LINE_LENGTH, 75).
|
||||
--define(MIN_USAGE_COMMAND_LINE_OPTION_LENGTH, 25).
|
||||
-
|
||||
-%% Position of each field in the option specification tuple.
|
||||
--define(OPT_NAME, 1).
|
||||
|
@ -65,42 +78,89 @@ index 175b7a5..0000000
|
|||
--define(OPT_HELP, 5).
|
||||
-
|
||||
--define(IS_OPT_SPEC(Opt), (tuple_size(Opt) =:= ?OPT_HELP)).
|
||||
-
|
||||
--define(IS_WHITESPACE(Char), ((Char) =:= $\s orelse (Char) =:= $\t orelse
|
||||
- (Char) =:= $\n orelse (Char) =:= $\r)).
|
||||
-
|
||||
-%% Atom indicating the data type that an argument can be converted to.
|
||||
--type arg_type() :: 'atom' | 'binary' | 'boolean' | 'float' | 'integer' | 'string'.
|
||||
--type arg_type() :: 'atom' | 'binary' | 'boolean' | 'float' | 'integer' | 'string'.
|
||||
-%% Data type that an argument can be converted to.
|
||||
--type arg_value() :: atom() | binary() | boolean() | float() | integer() | string().
|
||||
--type arg_value() :: atom() | binary() | boolean() | float() | integer() | string().
|
||||
-%% Argument specification.
|
||||
--type arg_spec() :: arg_type() | {arg_type(), arg_value()} | undefined.
|
||||
--type arg_spec() :: arg_type() | {arg_type(), arg_value()} | undefined.
|
||||
-%% Option type and optional default argument.
|
||||
--type simple_option() :: atom().
|
||||
--type compound_option() :: {atom(), arg_value()}.
|
||||
--type option() :: simple_option() | compound_option().
|
||||
--type simple_option() :: atom().
|
||||
--type compound_option() :: {atom(), arg_value()}.
|
||||
--type option() :: simple_option() | compound_option().
|
||||
-%% Command line option specification.
|
||||
--type option_spec() :: {
|
||||
- Name :: atom(),
|
||||
- Short :: char() | undefined,
|
||||
- Long :: string() | undefined,
|
||||
- ArgSpec :: arg_spec(),
|
||||
- Help :: string() | undefined
|
||||
- Name :: atom(),
|
||||
- Short :: char() | undefined,
|
||||
- Long :: string() | undefined,
|
||||
- ArgSpec :: arg_spec(),
|
||||
- Help :: string() | undefined
|
||||
- }.
|
||||
-%% Output streams
|
||||
--type output_stream() :: 'standard_io' | 'standard_error'.
|
||||
--type output_stream() :: 'standard_io' | 'standard_error'.
|
||||
-
|
||||
-%% For internal use
|
||||
--type usage_line() :: {OptionText :: string(), HelpText :: string()}.
|
||||
--type usage_line_with_length() :: {OptionLength :: non_neg_integer(), OptionText :: string(), HelpText :: string()}.
|
||||
-
|
||||
-
|
||||
-%% @doc Parse the command line options and arguments returning a list of tuples
|
||||
-%% and/or atoms using the Erlang convention for sending options to a
|
||||
-%% function.
|
||||
--export_type([arg_type/0, arg_value/0, arg_spec/0, simple_option/0, compound_option/0, option/0, option_spec/0]).
|
||||
-
|
||||
-
|
||||
-%% @doc Parse the command line options and arguments returning a list of tuples
|
||||
-%% and/or atoms using the Erlang convention for sending options to a
|
||||
-%% function. Additionally perform check if all required options (the ones
|
||||
-%% without default values) are present. The function is a combination of
|
||||
-%% two calls: parse/2 and check/2.
|
||||
--spec parse_and_check([option_spec()], string() | [string()]) ->
|
||||
- {ok, {[option()], [string()]}} | {error, {Reason :: atom(), Data :: term()}}.
|
||||
-parse_and_check(OptSpecList, CmdLine) when is_list(OptSpecList), is_list(CmdLine) ->
|
||||
- case parse(OptSpecList, CmdLine) of
|
||||
- {ok, {Opts, _}} = Result ->
|
||||
- case check(OptSpecList, Opts) of
|
||||
- ok -> Result;
|
||||
- Error -> Error
|
||||
- end;
|
||||
- Error ->
|
||||
- Error
|
||||
- end.
|
||||
-
|
||||
-%% @doc Check the parsed command line arguments returning ok if all required
|
||||
-%% options (i.e. that don't have defaults) are present, and returning
|
||||
-%% error otherwise.
|
||||
--spec check([option_spec()], [option()]) ->
|
||||
- ok | {error, {Reason :: atom(), Option :: atom()}}.
|
||||
-check(OptSpecList, ParsedOpts) when is_list(OptSpecList), is_list(ParsedOpts) ->
|
||||
- try
|
||||
- RequiredOpts = [Name || {Name, _, _, Arg, _} <- OptSpecList,
|
||||
- not is_tuple(Arg) andalso Arg =/= undefined],
|
||||
- lists:foreach(fun (Option) ->
|
||||
- case proplists:is_defined(Option, ParsedOpts) of
|
||||
- true ->
|
||||
- ok;
|
||||
- false ->
|
||||
- throw({error, {missing_required_option, Option}})
|
||||
- end
|
||||
- end, RequiredOpts)
|
||||
- catch
|
||||
- _:Error ->
|
||||
- Error
|
||||
- end.
|
||||
-
|
||||
-
|
||||
-%% @doc Parse the command line options and arguments returning a list of tuples
|
||||
-%% and/or atoms using the Erlang convention for sending options to a
|
||||
-%% function.
|
||||
--spec parse([option_spec()], string() | [string()]) ->
|
||||
- {ok, {[option()], [string()]}} | {error, {Reason :: atom(), Data :: any()}}.
|
||||
-parse(OptSpecList, CmdLine) ->
|
||||
- {ok, {[option()], [string()]}} | {error, {Reason :: atom(), Data :: term()}}.
|
||||
-parse(OptSpecList, CmdLine) when is_list(CmdLine) ->
|
||||
- try
|
||||
- Args = if
|
||||
- is_integer(hd(CmdLine)) ->
|
||||
- string:tokens(CmdLine, " \t\n");
|
||||
- true ->
|
||||
- CmdLine
|
||||
- is_integer(hd(CmdLine)) -> tokenize(CmdLine);
|
||||
- true -> CmdLine
|
||||
- end,
|
||||
- parse(OptSpecList, [], [], 0, Args)
|
||||
- catch
|
||||
|
@ -110,7 +170,7 @@ index 175b7a5..0000000
|
|||
-
|
||||
-
|
||||
--spec parse([option_spec()], [option()], [string()], integer(), [string()]) ->
|
||||
- {ok, {[option()], [string()]}}.
|
||||
- {ok, {[option()], [string()]}}.
|
||||
-%% Process the option terminator.
|
||||
-parse(OptSpecList, OptAcc, ArgAcc, _ArgPos, ["--" | Tail]) ->
|
||||
- %% Any argument present after the terminator is not considered an option.
|
||||
|
@ -135,6 +195,24 @@ index 175b7a5..0000000
|
|||
- {ok, {lists:reverse(append_default_options(OptSpecList, OptAcc)), lists:reverse(ArgAcc)}}.
|
||||
-
|
||||
-
|
||||
-%% @doc Format the error code returned by prior call to parse/2 or check/2.
|
||||
--spec format_error([option_spec()], {error, {Reason :: atom(), Data :: term()}} |
|
||||
- {Reason :: term(), Data :: term()}) -> string().
|
||||
-format_error(OptSpecList, {error, Reason}) ->
|
||||
- format_error(OptSpecList, Reason);
|
||||
-format_error(OptSpecList, {missing_required_option, Name}) ->
|
||||
- {_Name, Short, Long, _Type, _Help} = lists:keyfind(Name, 1, OptSpecList),
|
||||
- lists:flatten(["missing required option: -", [Short], " (", to_string(Long), ")"]);
|
||||
-format_error(_OptSpecList, {invalid_option, OptStr}) ->
|
||||
- lists:flatten(["invalid option: ", to_string(OptStr)]);
|
||||
-format_error(_OptSpecList, {invalid_option_arg, {Name, Arg}}) ->
|
||||
- lists:flatten(["option \'", to_string(Name) ++ "\' has invalid argument: ", to_string(Arg)]);
|
||||
-format_error(_OptSpecList, {invalid_option_arg, OptStr}) ->
|
||||
- lists:flatten(["invalid option argument: ", to_string(OptStr)]);
|
||||
-format_error(_OptSpecList, {Reason, Data}) ->
|
||||
- lists:flatten([to_string(Reason), " ", to_string(Data)]).
|
||||
-
|
||||
-
|
||||
-%% @doc Parse a long option, add it to the option accumulator and continue
|
||||
-%% parsing the rest of the arguments recursively.
|
||||
-%% A long option can have the following syntax:
|
||||
|
@ -142,7 +220,7 @@ index 175b7a5..0000000
|
|||
-%% --foo=bar Single option 'foo', argument "bar"
|
||||
-%% --foo bar Single option 'foo', argument "bar"
|
||||
--spec parse_long_option([option_spec()], [option()], [string()], integer(), [string()], string(), string()) ->
|
||||
- {ok, {[option()], [string()]}}.
|
||||
- {ok, {[option()], [string()]}}.
|
||||
-parse_long_option(OptSpecList, OptAcc, ArgAcc, ArgPos, Args, OptStr, OptArg) ->
|
||||
- case split_assigned_arg(OptArg) of
|
||||
- {Long, Arg} ->
|
||||
|
@ -229,7 +307,7 @@ index 175b7a5..0000000
|
|||
-%% -bcafoo Multiple options: 'b'; 'c'; 'a' with argument "foo"
|
||||
-%% -aaa Multiple repetitions of option 'a' (only valid for options with integer arguments)
|
||||
--spec parse_short_option([option_spec()], [option()], [string()], integer(), [string()], string(), string()) ->
|
||||
- {ok, {[option()], [string()]}}.
|
||||
- {ok, {[option()], [string()]}}.
|
||||
-parse_short_option(OptSpecList, OptAcc, ArgAcc, ArgPos, Args, OptStr, OptArg) ->
|
||||
- parse_short_option(OptSpecList, OptAcc, ArgAcc, ArgPos, Args, OptStr, first, OptArg).
|
||||
-
|
||||
|
@ -290,7 +368,7 @@ index 175b7a5..0000000
|
|||
-%% Pos argument.
|
||||
--spec find_non_option_arg([option_spec()], integer()) -> {value, option_spec()} | false.
|
||||
-find_non_option_arg([{_Name, undefined, undefined, _ArgSpec, _Help} = OptSpec | _Tail], 0) ->
|
||||
- {value, OptSpec};
|
||||
- {value, OptSpec};
|
||||
-find_non_option_arg([{_Name, undefined, undefined, _ArgSpec, _Help} | Tail], Pos) ->
|
||||
- find_non_option_arg(Tail, Pos - 1);
|
||||
-find_non_option_arg([_Head | Tail], Pos) ->
|
||||
|
@ -304,12 +382,12 @@ index 175b7a5..0000000
|
|||
--spec append_default_options([option_spec()], [option()]) -> [option()].
|
||||
-append_default_options([{Name, _Short, _Long, {_Type, DefaultArg}, _Help} | Tail], OptAcc) ->
|
||||
- append_default_options(Tail,
|
||||
- case lists:keymember(Name, 1, OptAcc) of
|
||||
- false ->
|
||||
- [{Name, DefaultArg} | OptAcc];
|
||||
- _ ->
|
||||
- OptAcc
|
||||
- end);
|
||||
- case lists:keymember(Name, 1, OptAcc) of
|
||||
- false ->
|
||||
- [{Name, DefaultArg} | OptAcc];
|
||||
- _ ->
|
||||
- OptAcc
|
||||
- end);
|
||||
-%% For options with no default argument.
|
||||
-append_default_options([_Head | Tail], OptAcc) ->
|
||||
- append_default_options(Tail, OptAcc);
|
||||
|
@ -502,155 +580,390 @@ index 175b7a5..0000000
|
|||
-%% arguments that are supported by the program.
|
||||
--spec usage([option_spec()], string()) -> ok.
|
||||
-usage(OptSpecList, ProgramName) ->
|
||||
- usage(OptSpecList, ProgramName, standard_error).
|
||||
- usage(OptSpecList, ProgramName, standard_error).
|
||||
-
|
||||
-
|
||||
-%% @doc Show a message on standard_error or standard_io indicating the command line options and
|
||||
-%% arguments that are supported by the program.
|
||||
--spec usage([option_spec()], string(), output_stream() | string()) -> ok.
|
||||
-usage(OptSpecList, ProgramName, OutputStream) when is_atom(OutputStream) ->
|
||||
- io:format(OutputStream, "Usage: ~s~s~n~n~s~n",
|
||||
- [ProgramName, usage_cmd_line(OptSpecList), usage_options(OptSpecList)]);
|
||||
- io:format(OutputStream, "~s~n~n~s~n",
|
||||
- [usage_cmd_line(ProgramName, OptSpecList), usage_options(OptSpecList)]);
|
||||
-%% @doc Show a message on standard_error indicating the command line options and
|
||||
-%% arguments that are supported by the program. The CmdLineTail argument
|
||||
-%% is a string that is added to the end of the usage command line.
|
||||
-usage(OptSpecList, ProgramName, CmdLineTail) ->
|
||||
- usage(OptSpecList, ProgramName, CmdLineTail, standard_error).
|
||||
- usage(OptSpecList, ProgramName, CmdLineTail, standard_error).
|
||||
-
|
||||
-
|
||||
-%% @doc Show a message on standard_error or standard_io indicating the command line options and
|
||||
-%% arguments that are supported by the program. The CmdLineTail argument
|
||||
-%% is a string that is added to the end of the usage command line.
|
||||
--spec usage([option_spec()], string(), string(), output_stream() | [{string(), string()}]) -> ok.
|
||||
--spec usage([option_spec()], ProgramName :: string(), CmdLineTail :: string(), output_stream() | [{string(), string()}]) -> ok.
|
||||
-usage(OptSpecList, ProgramName, CmdLineTail, OutputStream) when is_atom(OutputStream) ->
|
||||
- io:format(OutputStream, "Usage: ~s~s ~s~n~n~s~n",
|
||||
- [ProgramName, usage_cmd_line(OptSpecList), CmdLineTail, usage_options(OptSpecList)]);
|
||||
- io:format(OutputStream, "~s~n~n~s~n",
|
||||
- [usage_cmd_line(ProgramName, OptSpecList, CmdLineTail), usage_options(OptSpecList)]);
|
||||
-%% @doc Show a message on standard_error indicating the command line options and
|
||||
-%% arguments that are supported by the program. The CmdLineTail and OptionsTail
|
||||
-%% arguments are a string that is added to the end of the usage command line
|
||||
-%% and a list of tuples that are added to the end of the options' help lines.
|
||||
-usage(OptSpecList, ProgramName, CmdLineTail, OptionsTail) ->
|
||||
- usage(OptSpecList, ProgramName, CmdLineTail, OptionsTail, standard_error).
|
||||
- usage(OptSpecList, ProgramName, CmdLineTail, OptionsTail, standard_error).
|
||||
-
|
||||
-
|
||||
-%% @doc Show a message on standard_error or standard_io indicating the command line options and
|
||||
-%% arguments that are supported by the program. The CmdLineTail and OptionsTail
|
||||
-%% arguments are a string that is added to the end of the usage command line
|
||||
-%% and a list of tuples that are added to the end of the options' help lines.
|
||||
--spec usage([option_spec()], string(), string(), [{string(), string()}], output_stream()) -> ok.
|
||||
--spec usage([option_spec()], ProgramName :: string(), CmdLineTail :: string(),
|
||||
- [{OptionName :: string(), Help :: string()}], output_stream()) -> ok.
|
||||
-usage(OptSpecList, ProgramName, CmdLineTail, OptionsTail, OutputStream) ->
|
||||
- UsageOptions = lists:foldl(
|
||||
- fun ({Prefix, Help}, Acc) ->
|
||||
- add_option_help(Prefix, Help, Acc)
|
||||
- end, usage_options_reverse(OptSpecList, []), OptionsTail),
|
||||
- io:format(OutputStream, "Usage: ~s~s ~s~n~n~s~n",
|
||||
- [ProgramName, usage_cmd_line(OptSpecList), CmdLineTail,
|
||||
- lists:flatten(lists:reverse(UsageOptions))]).
|
||||
- io:format(OutputStream, "~s~n~n~s~n",
|
||||
- [usage_cmd_line(ProgramName, OptSpecList, CmdLineTail), usage_options(OptSpecList, OptionsTail)]).
|
||||
-
|
||||
-
|
||||
-%% @doc Return a string with the syntax for the command line options and
|
||||
-%% arguments.
|
||||
--spec usage_cmd_line([option_spec()]) -> string().
|
||||
-usage_cmd_line(OptSpecList) ->
|
||||
- usage_cmd_line(OptSpecList, []).
|
||||
--spec usage_cmd_line(ProgramName :: string(), [option_spec()]) -> iolist().
|
||||
-usage_cmd_line(ProgramName, OptSpecList) ->
|
||||
- usage_cmd_line(ProgramName, OptSpecList, "").
|
||||
-
|
||||
-usage_cmd_line([{Name, Short, Long, ArgSpec, _Help} | Tail], Acc) ->
|
||||
- CmdLine =
|
||||
- case ArgSpec of
|
||||
- undefined ->
|
||||
- if
|
||||
- %% For options with short form and no argument.
|
||||
- Short =/= undefined ->
|
||||
- [$\s, $[, $-, Short, $]];
|
||||
- %% For options with only long form and no argument.
|
||||
- Long =/= undefined ->
|
||||
- [$\s, $[, $-, $-, Long, $]];
|
||||
- true ->
|
||||
- []
|
||||
- end;
|
||||
- _ ->
|
||||
- if
|
||||
- %% For options with short form and argument.
|
||||
- Short =/= undefined ->
|
||||
- [$\s, $[, $-, Short, $\s, $<, atom_to_list(Name), $>, $]];
|
||||
- %% For options with only long form and argument.
|
||||
- Long =/= undefined ->
|
||||
- [$\s, $[, $-, $-, Long, $\s, $<, atom_to_list(Name), $>, $]];
|
||||
- %% For options with neither short nor long form and argument.
|
||||
- true ->
|
||||
- [$\s, $<, atom_to_list(Name), $>]
|
||||
- end
|
||||
- end,
|
||||
- usage_cmd_line(Tail, [CmdLine | Acc]);
|
||||
-usage_cmd_line([], Acc) ->
|
||||
- lists:flatten(lists:reverse(Acc)).
|
||||
-
|
||||
-
|
||||
-%% @doc Return a string with the help message for each of the options and
|
||||
-%% arguments.
|
||||
--spec usage_options([option_spec()]) -> string().
|
||||
-usage_options(OptSpecList) ->
|
||||
- lists:flatten(lists:reverse(usage_options_reverse(OptSpecList, []))).
|
||||
-
|
||||
-usage_options_reverse([{Name, Short, Long, _ArgSpec, Help} | Tail], Acc) ->
|
||||
- Prefix =
|
||||
- case Long of
|
||||
- undefined ->
|
||||
- case Short of
|
||||
- %% Neither short nor long form (non-option argument).
|
||||
- undefined ->
|
||||
- [$<, atom_to_list(Name), $>];
|
||||
- %% Only short form.
|
||||
- _ ->
|
||||
- [$-, Short]
|
||||
- end;
|
||||
- _ ->
|
||||
- case Short of
|
||||
- %% Only long form.
|
||||
- undefined ->
|
||||
- [$-, $- | Long];
|
||||
- %% Both short and long form.
|
||||
- _ ->
|
||||
- [$-, Short, $,, $\s, $-, $- | Long]
|
||||
- end
|
||||
- end,
|
||||
- usage_options_reverse(Tail, add_option_help(Prefix, Help, Acc));
|
||||
-usage_options_reverse([], Acc) ->
|
||||
- Acc.
|
||||
-
|
||||
-
|
||||
-%% @doc Add the help message corresponding to an option specification to a list
|
||||
-%% with the correct indentation.
|
||||
--spec add_option_help(Prefix :: string(), Help :: string(), Acc :: string()) -> string().
|
||||
-add_option_help(Prefix, Help, Acc) when is_list(Help), Help =/= [] ->
|
||||
- FlatPrefix = lists:flatten(Prefix),
|
||||
- case ((?INDENTATION * ?TAB_LENGTH) - 2 - length(FlatPrefix)) of
|
||||
- TabSize when TabSize > 0 ->
|
||||
- Tab = lists:duplicate(ceiling(TabSize / ?TAB_LENGTH), $\t),
|
||||
- [[$\s, $\s, FlatPrefix, Tab, Help, $\n] | Acc];
|
||||
- _ ->
|
||||
- % The indentation for the option description is 3 tabs (i.e. 24 characters)
|
||||
- % IMPORTANT: Change the number of tabs below if you change the
|
||||
- % value of the INDENTATION macro.
|
||||
- [[$\t, $\t, $\t, Help, $\n], [$\s, $\s, FlatPrefix, $\n] | Acc]
|
||||
- end;
|
||||
-add_option_help(_Opt, _Prefix, Acc) ->
|
||||
- Acc.
|
||||
-
|
||||
-
|
||||
-
|
||||
-%% @doc Return the smallest integral value not less than the argument.
|
||||
--spec ceiling(float()) -> integer().
|
||||
-ceiling(X) ->
|
||||
- T = erlang:trunc(X),
|
||||
- case (X - T) of
|
||||
- % Neg when Neg < 0 ->
|
||||
- % T;
|
||||
- Pos when Pos > 0 ->
|
||||
- T + 1;
|
||||
- _ ->
|
||||
- T
|
||||
--spec usage_cmd_line(ProgramName :: string(), [option_spec()], CmdLineTail :: string()) -> iolist().
|
||||
-usage_cmd_line(ProgramName, OptSpecList, CmdLineTail) ->
|
||||
- Prefix = "Usage: " ++ ProgramName,
|
||||
- PrefixLength = length(Prefix),
|
||||
- LineLength = line_length(),
|
||||
- %% Only align the command line options after the program name when there is
|
||||
- %% enough room to do so (i.e. at least 25 characters). If not, show the
|
||||
- %% command line options below the program name with a 2-character indentation.
|
||||
- if
|
||||
- (LineLength - PrefixLength) > ?MIN_USAGE_COMMAND_LINE_OPTION_LENGTH ->
|
||||
- Indentation = lists:duplicate(PrefixLength, $\s),
|
||||
- [FirstOptLine | OptLines] = usage_cmd_line_options(LineLength - PrefixLength, OptSpecList, CmdLineTail),
|
||||
- IndentedOptLines = [[Indentation | OptLine] || OptLine <- OptLines],
|
||||
- [Prefix, FirstOptLine | IndentedOptLines];
|
||||
- true ->
|
||||
- IndentedOptLines = [[" " | OptLine] || OptLine <- usage_cmd_line_options(LineLength, OptSpecList, CmdLineTail)],
|
||||
- [Prefix, $\n, IndentedOptLines]
|
||||
- end.
|
||||
-
|
||||
-
|
||||
-%% @doc Return a list of the lines corresponding to the usage command line
|
||||
-%% already wrapped according to the maximum MaxLineLength.
|
||||
--spec usage_cmd_line_options(MaxLineLength :: non_neg_integer(), [option_spec()], CmdLineTail :: string()) -> iolist().
|
||||
-usage_cmd_line_options(MaxLineLength, OptSpecList, CmdLineTail) ->
|
||||
- usage_cmd_line_options(MaxLineLength, OptSpecList ++ string:tokens(CmdLineTail, " "), [], 0, []).
|
||||
-
|
||||
-usage_cmd_line_options(MaxLineLength, [OptSpec | Tail], LineAcc, LineAccLength, Acc) ->
|
||||
- Option = [$\s | lists:flatten(usage_cmd_line_option(OptSpec))],
|
||||
- OptionLength = length(Option),
|
||||
- %% We accumulate the options in LineAcc until its length is over the
|
||||
- %% maximum allowed line length. When that happens, we append the line in
|
||||
- %% LineAcc to the list with all the lines in the command line (Acc).
|
||||
- NewLineAccLength = LineAccLength + OptionLength,
|
||||
- if
|
||||
- NewLineAccLength < MaxLineLength ->
|
||||
- usage_cmd_line_options(MaxLineLength, Tail, [Option | LineAcc], NewLineAccLength, Acc);
|
||||
- true ->
|
||||
- usage_cmd_line_options(MaxLineLength, Tail, [Option], OptionLength + 1,
|
||||
- [lists:reverse([$\n | LineAcc]) | Acc])
|
||||
- end;
|
||||
-usage_cmd_line_options(MaxLineLength, [], [_ | _] = LineAcc, _LineAccLength, Acc) ->
|
||||
- %% If there was a non-empty line in LineAcc when there are no more options
|
||||
- %% to process, we add it to the list of lines to return.
|
||||
- usage_cmd_line_options(MaxLineLength, [], [], 0, [lists:reverse(LineAcc) | Acc]);
|
||||
-usage_cmd_line_options(_MaxLineLength, [], [], _LineAccLength, Acc) ->
|
||||
- lists:reverse(Acc).
|
||||
-
|
||||
-
|
||||
--spec usage_cmd_line_option(option_spec()) -> string().
|
||||
-usage_cmd_line_option({_Name, Short, _Long, undefined, _Help}) when Short =/= undefined ->
|
||||
- %% For options with short form and no argument.
|
||||
- [$[, $-, Short, $]];
|
||||
-usage_cmd_line_option({_Name, _Short, Long, undefined, _Help}) when Long =/= undefined ->
|
||||
- %% For options with only long form and no argument.
|
||||
- [$[, $-, $-, Long, $]];
|
||||
-usage_cmd_line_option({_Name, _Short, _Long, undefined, _Help}) ->
|
||||
- [];
|
||||
-usage_cmd_line_option({Name, Short, Long, ArgSpec, _Help}) when is_atom(ArgSpec) ->
|
||||
- %% For options with no default argument.
|
||||
- if
|
||||
- %% For options with short form and argument.
|
||||
- Short =/= undefined -> [$[, $-, Short, $\s, $<, atom_to_list(Name), $>, $]];
|
||||
- %% For options with only long form and argument.
|
||||
- Long =/= undefined -> [$[, $-, $-, Long, $\s, $<, atom_to_list(Name), $>, $]];
|
||||
- %% For options with neither short nor long form and argument.
|
||||
- true -> [$[, $<, atom_to_list(Name), $>, $]]
|
||||
- end;
|
||||
-usage_cmd_line_option({Name, Short, Long, ArgSpec, _Help}) when is_tuple(ArgSpec) ->
|
||||
- %% For options with default argument.
|
||||
- if
|
||||
- %% For options with short form and default argument.
|
||||
- Short =/= undefined -> [$[, $-, Short, $\s, $[, $<, atom_to_list(Name), $>, $], $]];
|
||||
- %% For options with only long form and default argument.
|
||||
- Long =/= undefined -> [$[, $-, $-, Long, $\s, $[, $<, atom_to_list(Name), $>, $], $]];
|
||||
- %% For options with neither short nor long form and default argument.
|
||||
- true -> [$[, $<, atom_to_list(Name), $>, $]]
|
||||
- end;
|
||||
-usage_cmd_line_option(Option) when is_list(Option) ->
|
||||
- %% For custom options that are added to the command line.
|
||||
- Option.
|
||||
-
|
||||
-
|
||||
-%% @doc Return a list of help messages to print for each of the options and arguments.
|
||||
--spec usage_options([option_spec()]) -> [string()].
|
||||
-usage_options(OptSpecList) ->
|
||||
- usage_options(OptSpecList, []).
|
||||
-
|
||||
-
|
||||
-%% @doc Return a list of usage lines to print for each of the options and arguments.
|
||||
--spec usage_options([option_spec()], [{OptionName :: string(), Help :: string()}]) -> [string()].
|
||||
-usage_options(OptSpecList, CustomHelp) ->
|
||||
- %% Add the usage lines corresponding to the option specifications.
|
||||
- {MaxOptionLength0, UsageLines0} = add_option_spec_help_lines(OptSpecList, 0, []),
|
||||
- %% Add the custom usage lines.
|
||||
- {MaxOptionLength, UsageLines} = add_custom_help_lines(CustomHelp, MaxOptionLength0, UsageLines0),
|
||||
- MaxLineLength = line_length(),
|
||||
- lists:reverse([format_usage_line(MaxOptionLength + 1, MaxLineLength, UsageLine) || UsageLine <- UsageLines]).
|
||||
-
|
||||
-
|
||||
--spec add_option_spec_help_lines([option_spec()], PrevMaxOptionLength :: non_neg_integer(), [usage_line_with_length()]) ->
|
||||
- {MaxOptionLength :: non_neg_integer(), [usage_line_with_length()]}.
|
||||
-add_option_spec_help_lines([OptSpec | Tail], PrevMaxOptionLength, Acc) ->
|
||||
- OptionText = usage_option_text(OptSpec),
|
||||
- HelpText = usage_help_text(OptSpec),
|
||||
- {MaxOptionLength, ColsWithLength} = get_max_option_length({OptionText, HelpText}, PrevMaxOptionLength),
|
||||
- add_option_spec_help_lines(Tail, MaxOptionLength, [ColsWithLength | Acc]);
|
||||
-add_option_spec_help_lines([], MaxOptionLength, Acc) ->
|
||||
- {MaxOptionLength, Acc}.
|
||||
-
|
||||
-
|
||||
--spec add_custom_help_lines([usage_line()], PrevMaxOptionLength :: non_neg_integer(), [usage_line_with_length()]) ->
|
||||
- {MaxOptionLength :: non_neg_integer(), [usage_line_with_length()]}.
|
||||
-add_custom_help_lines([CustomCols | Tail], PrevMaxOptionLength, Acc) ->
|
||||
- {MaxOptionLength, ColsWithLength} = get_max_option_length(CustomCols, PrevMaxOptionLength),
|
||||
- add_custom_help_lines(Tail, MaxOptionLength, [ColsWithLength | Acc]);
|
||||
-add_custom_help_lines([], MaxOptionLength, Acc) ->
|
||||
- {MaxOptionLength, Acc}.
|
||||
-
|
||||
-
|
||||
--spec usage_option_text(option_spec()) -> string().
|
||||
-usage_option_text({Name, undefined, undefined, _ArgSpec, _Help}) ->
|
||||
- %% Neither short nor long form (non-option argument).
|
||||
- "<" ++ atom_to_list(Name) ++ ">";
|
||||
-usage_option_text({_Name, Short, undefined, _ArgSpec, _Help}) ->
|
||||
- %% Only short form.
|
||||
- [$-, Short];
|
||||
-usage_option_text({_Name, undefined, Long, _ArgSpec, _Help}) ->
|
||||
- %% Only long form.
|
||||
- [$-, $- | Long];
|
||||
-usage_option_text({_Name, Short, Long, _ArgSpec, _Help}) ->
|
||||
- %% Both short and long form.
|
||||
- [$-, Short, $,, $\s, $-, $- | Long].
|
||||
-
|
||||
-
|
||||
--spec usage_help_text(option_spec()) -> string().
|
||||
-usage_help_text({_Name, _Short, _Long, {_ArgType, ArgValue}, [_ | _] = Help}) ->
|
||||
- Help ++ " [default: " ++ default_arg_value_to_string(ArgValue) ++ "]";
|
||||
-usage_help_text({_Name, _Short, _Long, _ArgSpec, Help}) ->
|
||||
- Help.
|
||||
-
|
||||
-
|
||||
-%% @doc Calculate the maximum width of the column that shows the option's short
|
||||
-%% and long form.
|
||||
--spec get_max_option_length(usage_line(), PrevMaxOptionLength :: non_neg_integer()) ->
|
||||
- {MaxOptionLength :: non_neg_integer(), usage_line_with_length()}.
|
||||
-get_max_option_length({OptionText, HelpText}, PrevMaxOptionLength) ->
|
||||
- OptionLength = length(OptionText),
|
||||
- {erlang:max(OptionLength, PrevMaxOptionLength), {OptionLength, OptionText, HelpText}}.
|
||||
-
|
||||
-
|
||||
-%% @doc Format the usage line that is shown for the options' usage. Each usage
|
||||
-%% line has 2 columns. The first column shows the options in their short
|
||||
-%% and long form. The second column shows the wrapped (if necessary) help
|
||||
-%% text lines associated with each option. e.g.:
|
||||
-%%
|
||||
-%% -h, --host Database server host name or IP address; this is the
|
||||
-%% hostname of the server where the database is running
|
||||
-%% [default: localhost]
|
||||
-%% -p, --port Database server port [default: 1000]
|
||||
-%%
|
||||
--spec format_usage_line(MaxOptionLength :: non_neg_integer(), MaxLineLength :: non_neg_integer(),
|
||||
- usage_line_with_length()) -> iolist().
|
||||
-format_usage_line(MaxOptionLength, MaxLineLength, {OptionLength, OptionText, [_ | _] = HelpText})
|
||||
- when MaxOptionLength < (MaxLineLength div 2) ->
|
||||
- %% If the width of the column where the options are shown is smaller than
|
||||
- %% half the width of a console line then we show the help text line aligned
|
||||
- %% next to its corresponding option, with a separation of at least 2
|
||||
- %% characters.
|
||||
- [Head | Tail] = wrap_text_line(MaxLineLength - MaxOptionLength - 3, HelpText),
|
||||
- FirstLineIndentation = lists:duplicate(MaxOptionLength - OptionLength + 1, $\s),
|
||||
- Indentation = [$\n | lists:duplicate(MaxOptionLength + 3, $\s)],
|
||||
- [" ", OptionText, FirstLineIndentation, Head,
|
||||
- [[Indentation, Line] || Line <- Tail], $\n];
|
||||
-format_usage_line(_MaxOptionLength, MaxLineLength, {_OptionLength, OptionText, [_ | _] = HelpText}) ->
|
||||
- %% If the width of the first column is bigger than the width of a console
|
||||
- %% line, we show the help text on the next line with an indentation of 6
|
||||
- %% characters.
|
||||
- HelpLines = wrap_text_line(MaxLineLength - 6, HelpText),
|
||||
- [" ", OptionText, [["\n ", Line] || Line <- HelpLines], $\n];
|
||||
-format_usage_line(_MaxOptionLength, _MaxLineLength, {_OptionLength, OptionText, _HelpText}) ->
|
||||
- [" ", OptionText, $\n].
|
||||
-
|
||||
-
|
||||
-%% @doc Wrap a text line converting it into several text lines so that the
|
||||
-%% length of each one of them is never over Length characters.
|
||||
--spec wrap_text_line(Length :: non_neg_integer(), Text :: string()) -> [string()].
|
||||
-wrap_text_line(Length, Text) ->
|
||||
- wrap_text_line(Length, Text, [], 0, []).
|
||||
-
|
||||
-wrap_text_line(Length, [Char | Tail], Acc, Count, CurrentLineAcc) when Count < Length ->
|
||||
- wrap_text_line(Length, Tail, Acc, Count + 1, [Char | CurrentLineAcc]);
|
||||
-wrap_text_line(Length, [_ | _] = Help, Acc, Count, CurrentLineAcc) ->
|
||||
- %% Look for the first whitespace character in the current (reversed) line
|
||||
- %% buffer to get a wrapped line. If there is no whitespace just cut the
|
||||
- %% line at the position corresponding to the maximum length.
|
||||
- {NextLineAcc, WrappedLine} = case string:cspan(CurrentLineAcc, " \t") of
|
||||
- WhitespacePos when WhitespacePos < Count ->
|
||||
- lists:split(WhitespacePos, CurrentLineAcc);
|
||||
- _ ->
|
||||
- {[], CurrentLineAcc}
|
||||
- end,
|
||||
- wrap_text_line(Length, Help, [lists:reverse(WrappedLine) | Acc], length(NextLineAcc), NextLineAcc);
|
||||
-wrap_text_line(_Length, [], Acc, _Count, [_ | _] = CurrentLineAcc) ->
|
||||
- %% If there was a non-empty line when we reached the buffer, add it to the accumulator
|
||||
- lists:reverse([lists:reverse(CurrentLineAcc) | Acc]);
|
||||
-wrap_text_line(_Length, [], Acc, _Count, _CurrentLineAcc) ->
|
||||
- lists:reverse(Acc).
|
||||
-
|
||||
-
|
||||
-default_arg_value_to_string(Value) when is_atom(Value) ->
|
||||
- atom_to_list(Value);
|
||||
-default_arg_value_to_string(Value) when is_binary(Value) ->
|
||||
- binary_to_list(Value);
|
||||
-default_arg_value_to_string(Value) when is_integer(Value) ->
|
||||
- integer_to_list(Value);
|
||||
-default_arg_value_to_string(Value) when is_float(Value) ->
|
||||
- lists:flatten(io_lib:format("~w", [Value]));
|
||||
-default_arg_value_to_string(Value) ->
|
||||
- Value.
|
||||
-
|
||||
-
|
||||
-%% @doc Tokenize a command line string with support for single and double
|
||||
-%% quoted arguments (needed for arguments that have embedded whitespace).
|
||||
-%% The function also supports the expansion of environment variables in
|
||||
-%% both the Unix (${VAR}; $VAR) and Windows (%VAR%) formats. It does NOT
|
||||
-%% support wildcard expansion of paths.
|
||||
--spec tokenize(CmdLine :: string()) -> [nonempty_string()].
|
||||
-tokenize(CmdLine) ->
|
||||
- tokenize(CmdLine, [], []).
|
||||
-
|
||||
--spec tokenize(CmdLine :: string(), Acc :: [string()], ArgAcc :: string()) -> [string()].
|
||||
-tokenize([Sep | Tail], Acc, ArgAcc) when ?IS_WHITESPACE(Sep) ->
|
||||
- NewAcc = case ArgAcc of
|
||||
- [_ | _] ->
|
||||
- %% Found separator: add to the list of arguments.
|
||||
- [lists:reverse(ArgAcc) | Acc];
|
||||
- [] ->
|
||||
- %% Found separator with no accumulated argument; discard it.
|
||||
- Acc
|
||||
- end,
|
||||
- tokenize(Tail, NewAcc, []);
|
||||
-tokenize([QuotationMark | Tail], Acc, ArgAcc) when QuotationMark =:= $"; QuotationMark =:= $' ->
|
||||
- %% Quoted argument (might contain spaces, tabs, etc.)
|
||||
- tokenize_quoted_arg(QuotationMark, Tail, Acc, ArgAcc);
|
||||
-tokenize([Char | _Tail] = CmdLine, Acc, ArgAcc) when Char =:= $$; Char =:= $% ->
|
||||
- %% Unix and Windows environment variable expansion: ${VAR}; $VAR; %VAR%
|
||||
- {NewCmdLine, Var} = expand_env_var(CmdLine),
|
||||
- tokenize(NewCmdLine, Acc, lists:reverse(Var, ArgAcc));
|
||||
-tokenize([$\\, Char | Tail], Acc, ArgAcc) ->
|
||||
- %% Escaped char.
|
||||
- tokenize(Tail, Acc, [Char | ArgAcc]);
|
||||
-tokenize([Char | Tail], Acc, ArgAcc) ->
|
||||
- tokenize(Tail, Acc, [Char | ArgAcc]);
|
||||
-tokenize([], Acc, []) ->
|
||||
- lists:reverse(Acc);
|
||||
-tokenize([], Acc, ArgAcc) ->
|
||||
- lists:reverse([lists:reverse(ArgAcc) | Acc]).
|
||||
-
|
||||
--spec tokenize_quoted_arg(QuotationMark :: char(), CmdLine :: string(), Acc :: [string()], ArgAcc :: string()) -> [string()].
|
||||
-tokenize_quoted_arg(QuotationMark, [QuotationMark | Tail], Acc, ArgAcc) ->
|
||||
- %% End of quoted argument
|
||||
- tokenize(Tail, Acc, ArgAcc);
|
||||
-tokenize_quoted_arg(QuotationMark, [$\\, Char | Tail], Acc, ArgAcc) ->
|
||||
- %% Escaped char.
|
||||
- tokenize_quoted_arg(QuotationMark, Tail, Acc, [Char | ArgAcc]);
|
||||
-tokenize_quoted_arg($" = QuotationMark, [Char | _Tail] = CmdLine, Acc, ArgAcc) when Char =:= $$; Char =:= $% ->
|
||||
- %% Unix and Windows environment variable expansion (only for double-quoted arguments): ${VAR}; $VAR; %VAR%
|
||||
- {NewCmdLine, Var} = expand_env_var(CmdLine),
|
||||
- tokenize_quoted_arg(QuotationMark, NewCmdLine, Acc, lists:reverse(Var, ArgAcc));
|
||||
-tokenize_quoted_arg(QuotationMark, [Char | Tail], Acc, ArgAcc) ->
|
||||
- tokenize_quoted_arg(QuotationMark, Tail, Acc, [Char | ArgAcc]);
|
||||
-tokenize_quoted_arg(_QuotationMark, CmdLine, Acc, ArgAcc) ->
|
||||
- tokenize(CmdLine, Acc, ArgAcc).
|
||||
-
|
||||
-
|
||||
--spec expand_env_var(CmdLine :: nonempty_string()) -> {string(), string()}.
|
||||
-expand_env_var(CmdLine) ->
|
||||
- case CmdLine of
|
||||
- "${" ++ Tail ->
|
||||
- expand_env_var("${", $}, Tail, []);
|
||||
- "$" ++ Tail ->
|
||||
- expand_env_var("$", Tail, []);
|
||||
- "%" ++ Tail ->
|
||||
- expand_env_var("%", $%, Tail, [])
|
||||
- end.
|
||||
-
|
||||
--spec expand_env_var(Prefix :: string(), EndMark :: char(), CmdLine :: string(), Acc :: string()) -> {string(), string()}.
|
||||
-expand_env_var(Prefix, EndMark, [Char | Tail], Acc)
|
||||
- when (Char >= $A andalso Char =< $Z) orelse (Char >= $a andalso Char =< $z) orelse
|
||||
- (Char >= $0 andalso Char =< $9) orelse (Char =:= $_) ->
|
||||
- expand_env_var(Prefix, EndMark, Tail, [Char | Acc]);
|
||||
-expand_env_var(Prefix, EndMark, [EndMark | Tail], Acc) ->
|
||||
- {Tail, get_env_var(Prefix, [EndMark], Acc)};
|
||||
-expand_env_var(Prefix, _EndMark, CmdLine, Acc) ->
|
||||
- {CmdLine, Prefix ++ lists:reverse(Acc)}.
|
||||
-
|
||||
-
|
||||
--spec expand_env_var(Prefix :: string(), CmdLine :: string(), Acc :: string()) -> {string(), string()}.
|
||||
-expand_env_var(Prefix, [Char | Tail], Acc)
|
||||
- when (Char >= $A andalso Char =< $Z) orelse (Char >= $a andalso Char =< $z) orelse
|
||||
- (Char >= $0 andalso Char =< $9) orelse (Char =:= $_) ->
|
||||
- expand_env_var(Prefix, Tail, [Char | Acc]);
|
||||
-expand_env_var(Prefix, CmdLine, Acc) ->
|
||||
- {CmdLine, get_env_var(Prefix, "", Acc)}.
|
||||
-
|
||||
-
|
||||
--spec get_env_var(Prefix :: string(), Suffix :: string(), Acc :: string()) -> string().
|
||||
-get_env_var(Prefix, Suffix, [_ | _] = Acc) ->
|
||||
- Name = lists:reverse(Acc),
|
||||
- %% Only expand valid/existing variables.
|
||||
- case os:getenv(Name) of
|
||||
- false -> Prefix ++ Name ++ Suffix;
|
||||
- Value -> Value
|
||||
- end;
|
||||
-get_env_var(Prefix, Suffix, []) ->
|
||||
- Prefix ++ Suffix.
|
||||
-
|
||||
-
|
||||
--spec line_length() -> 0..?LINE_LENGTH.
|
||||
-line_length() ->
|
||||
- case io:columns() of
|
||||
- {ok, Columns} when Columns < ?LINE_LENGTH ->
|
||||
- Columns - 1;
|
||||
- _ ->
|
||||
- ?LINE_LENGTH
|
||||
- end.
|
||||
-
|
||||
-
|
||||
--spec to_string(term()) -> string().
|
||||
-to_string(List) when is_list(List) ->
|
||||
- case io_lib:printable_list(List) of
|
||||
- true -> List;
|
||||
- false -> io_lib:format("~p", [List])
|
||||
- end;
|
||||
-to_string(Atom) when is_atom(Atom) ->
|
||||
- atom_to_list(Atom);
|
||||
-to_string(Value) ->
|
||||
- io_lib:format("~p", [Value]).
|
||||
--
|
||||
1.8.1.4
|
||||
2.1.0
|
||||
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
From 53508faa9cba923751653901ba21d6025da46e5b Mon Sep 17 00:00:00 2001
|
||||
From: Dave Smith <dizzyd@dizzyd.com>
|
||||
Date: Mon, 12 Nov 2012 20:18:00 -0700
|
||||
Subject: [PATCH 04/10] Be sure to filter empty sources (h/t to Tuncer and Joe
|
||||
Norton)
|
||||
|
||||
---
|
||||
src/rebar_port_compiler.erl | 21 +++++++++++----------
|
||||
1 file changed, 11 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl
|
||||
index 71b27a5..70ee308 100644
|
||||
--- a/src/rebar_port_compiler.erl
|
||||
+++ b/src/rebar_port_compiler.erl
|
||||
@@ -248,16 +248,17 @@ needs_link(SoName, NewBins) ->
|
||||
%%
|
||||
|
||||
get_specs(Config, AppFile) ->
|
||||
- case rebar_config:get_local(Config, port_specs, []) of
|
||||
- [] ->
|
||||
- %% No spec provided. Construct a spec
|
||||
- %% from old-school so_name and sources
|
||||
- [port_spec_from_legacy(Config, AppFile)];
|
||||
- PortSpecs ->
|
||||
- Filtered = filter_port_specs(PortSpecs),
|
||||
- OsType = os:type(),
|
||||
- [get_port_spec(Config, OsType, Spec) || Spec <- Filtered]
|
||||
- end.
|
||||
+ Specs = case rebar_config:get_local(Config, port_specs, []) of
|
||||
+ [] ->
|
||||
+ %% No spec provided. Construct a spec
|
||||
+ %% from old-school so_name and sources
|
||||
+ [port_spec_from_legacy(Config, AppFile)];
|
||||
+ PortSpecs ->
|
||||
+ Filtered = filter_port_specs(PortSpecs),
|
||||
+ OsType = os:type(),
|
||||
+ [get_port_spec(Config, OsType, Spec) || Spec <- Filtered]
|
||||
+ end,
|
||||
+ [S || S <- Specs, S#spec.sources /= []].
|
||||
|
||||
port_spec_from_legacy(Config, AppFile) ->
|
||||
%% Get the target from the so_name variable
|
||||
--
|
||||
1.8.1.4
|
||||
|
|
@ -1,41 +1,53 @@
|
|||
From ec4f8e74c6058e6ba61e9687cccf30ed9378dca2 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Lemenkov <lemenkov@gmail.com>
|
||||
Date: Sat, 2 Mar 2013 13:52:04 +0400
|
||||
Subject: [PATCH 08/10] Remove abnfc compiler support (n/a in Fedora/EPEL)
|
||||
From 80ec40458dbe04e10531f0ce6ac90207e9eeb7c7 Mon Sep 17 00:00:00 2001
|
||||
From: Filip Andres <filip@andresovi.net>
|
||||
Date: Mon, 29 Jun 2015 14:05:01 +0200
|
||||
Subject: [PATCH] remove abnfc
|
||||
|
||||
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
|
||||
---
|
||||
ebin/rebar.app | 2 -
|
||||
src/rebar_abnfc_compiler.erl | 108 -------------------------------------------
|
||||
2 files changed, 110 deletions(-)
|
||||
rebar.config | 1 -
|
||||
src/rebar_abnfc_compiler.erl | 123 -------------------------------------------
|
||||
3 files changed, 126 deletions(-)
|
||||
delete mode 100644 src/rebar_abnfc_compiler.erl
|
||||
|
||||
diff --git a/ebin/rebar.app b/ebin/rebar.app
|
||||
index cba8bf8..e84e905 100644
|
||||
index 152829d..0205d3f 100644
|
||||
--- a/ebin/rebar.app
|
||||
+++ b/ebin/rebar.app
|
||||
@@ -5,7 +5,6 @@
|
||||
[{description, "Rebar: Erlang Build Tool"},
|
||||
{vsn, "2.1.0-pre"},
|
||||
{vsn, "2.6.0"},
|
||||
{modules, [ rebar,
|
||||
- rebar_abnfc_compiler,
|
||||
rebar_app_utils,
|
||||
rebar_appups,
|
||||
rebar_asn1_compiler,
|
||||
@@ -61,7 +60,6 @@
|
||||
@@ -80,7 +79,6 @@
|
||||
%% Dir specific processing modules
|
||||
{modules, [
|
||||
{app_dir, [
|
||||
- rebar_abnfc_compiler,
|
||||
rebar_proto_compiler,
|
||||
rebar_protobuffs_compiler,
|
||||
rebar_neotoma_compiler,
|
||||
rebar_asn1_compiler,
|
||||
rebar_proto_gpb_compiler,
|
||||
diff --git a/rebar.config b/rebar.config
|
||||
index a3849ec..c72aef7 100644
|
||||
--- a/rebar.config
|
||||
+++ b/rebar.config
|
||||
@@ -20,7 +20,6 @@
|
||||
- (\"escript\":\"foldl\"/\"3\")
|
||||
- (\"eunit_test\":\"function_wrapper\"/\"2\")
|
||||
- (\"eflame\":\"apply\"/\"5\")
|
||||
- - (\"abnfc\":\"file\"/\"2\")
|
||||
- (\"erlydtl\":\"compile\"/\"3\")
|
||||
- (\"lfe_comp\":\"file\"/\"2\")
|
||||
- (\"neotoma\":\"file\"/\"2\")
|
||||
diff --git a/src/rebar_abnfc_compiler.erl b/src/rebar_abnfc_compiler.erl
|
||||
deleted file mode 100644
|
||||
index 0e6749a..0000000
|
||||
index 37731b5..0000000
|
||||
--- a/src/rebar_abnfc_compiler.erl
|
||||
+++ /dev/null
|
||||
@@ -1,108 +0,0 @@
|
||||
@@ -1,123 +0,0 @@
|
||||
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
|
||||
-%% ex: ts=4 sw=4 et
|
||||
-%% -------------------------------------------------------------------
|
||||
|
@ -85,6 +97,9 @@ index 0e6749a..0000000
|
|||
-
|
||||
--export([compile/2]).
|
||||
-
|
||||
-%% for internal use only
|
||||
--export([info/2]).
|
||||
-
|
||||
--include("rebar.hrl").
|
||||
-
|
||||
-%% ===================================================================
|
||||
|
@ -100,11 +115,23 @@ index 0e6749a..0000000
|
|||
- option(module_ext, DtlOpts) ++ ".erl",
|
||||
- fun compile_abnfc/3).
|
||||
-
|
||||
-
|
||||
-%% ===================================================================
|
||||
-%% Internal functions
|
||||
-%% ===================================================================
|
||||
-
|
||||
-info(help, compile) ->
|
||||
- ?CONSOLE(
|
||||
- "Build ABNF (*.abnf) sources.~n"
|
||||
- "~n"
|
||||
- "Valid rebar.config options:~n"
|
||||
- " ~p~n",
|
||||
- [
|
||||
- {abnfc_opts, [{doc_root, "src"},
|
||||
- {out_dir, "src"},
|
||||
- {source_ext, ".abnfc"},
|
||||
- {module_ext, ""}]}
|
||||
- ]).
|
||||
-
|
||||
-abnfc_opts(Config) ->
|
||||
- rebar_config:get(Config, abnfc_opts, []).
|
||||
-
|
||||
|
@ -145,5 +172,5 @@ index 0e6749a..0000000
|
|||
- end
|
||||
- end.
|
||||
--
|
||||
1.8.1.4
|
||||
2.1.0
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
From 15f315f3b3ec0d4e11186b9eabb9789b4c38b1b0 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Lemenkov <lemenkov@gmail.com>
|
||||
Date: Sat, 2 Mar 2013 13:52:35 +0400
|
||||
Subject: [PATCH 09/10] Adjust app version
|
||||
|
||||
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
|
||||
---
|
||||
ebin/rebar.app | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/ebin/rebar.app b/ebin/rebar.app
|
||||
index e84e905..3f0aabe 100644
|
||||
--- a/ebin/rebar.app
|
||||
+++ b/ebin/rebar.app
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
{application, rebar,
|
||||
[{description, "Rebar: Erlang Build Tool"},
|
||||
- {vsn, "2.1.0-pre"},
|
||||
+ {vsn, "2.1.0"},
|
||||
{modules, [ rebar,
|
||||
rebar_app_utils,
|
||||
rebar_appups,
|
||||
--
|
||||
1.8.1.4
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
From 4139a739f3cfafdb46e511f09b58644cd8c9addb Mon Sep 17 00:00:00 2001
|
||||
From: serge <saleyn@gmail.com>
|
||||
Date: Thu, 15 Nov 2012 16:34:06 -0500
|
||||
Subject: [PATCH 10/10] Fix default DTL compilation when no erlydtl_opts are
|
||||
provided
|
||||
|
||||
---
|
||||
src/rebar_erlydtl_compiler.erl | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/rebar_erlydtl_compiler.erl b/src/rebar_erlydtl_compiler.erl
|
||||
index b5fe899..aef41c5 100644
|
||||
--- a/src/rebar_erlydtl_compiler.erl
|
||||
+++ b/src/rebar_erlydtl_compiler.erl
|
||||
@@ -133,7 +133,7 @@ erlydtl_opts(Config) ->
|
||||
Tuples = [{K,V} || {K,V} <- Opts],
|
||||
case [L || L <- Opts, is_list(L), not io_lib:printable_list(L)] of
|
||||
[] ->
|
||||
- lists:keysort(1, Tuples);
|
||||
+ [lists:keysort(1, Tuples)];
|
||||
Lists ->
|
||||
lists:map(fun(L) ->
|
||||
lists:keysort(1, lists:foldl(fun({K,T}, Acc) ->
|
||||
--
|
||||
1.8.1.4
|
||||
|
Loading…
Reference in New Issue