Permalink
Browse files

Add experimental command line option --indices

This option allows command line users to specify their own custom list of indices, just like they were able to do in rebar.config.

Example:

$ agner build socketio --indices '[{github,"yrashk"},{github,"agner"}].'
  • Loading branch information...
1 parent 3088124 commit a09e5c302a82b83d4e8a384a9c832e54f945ac41 @yrashk yrashk committed Jun 24, 2011
Showing with 22 additions and 7 deletions.
  1. +22 −7 src/agner_main.erl
View
29 src/agner_main.erl
@@ -30,31 +30,35 @@ arg_proplist() ->
{homepage, $h, "homepage", boolean, "Show package homepage in the browser"},
{version, $v, "version", {string, "@master"}, "Version"},
{property, $p, "property", string, "Particular property to render instead of a full spec"},
- {spec, $s, "spec-file", string, "Use local specification file"}
+ {spec, $s, "spec-file", string, "Use local specification file"},
+ {indices, undefined, "indices", string, "Custom list of indices, as an Erlang term, followed by a dot. Example: '[{github,\"yrashk\"}].'"}
]}},
{"versions",
{versions,
"Show the available releases and flavours of a package",
[
{package, undefined, undefined, string, "Package name"},
{no_flavours, undefined, "no-flavours", {boolean, false}, "Don't show flavour versions"},
- {no_releases, undefined, "no-releases", {boolean, false}, "Don't show release versions"}
+ {no_releases, undefined, "no-releases", {boolean, false}, "Don't show release versions"},
+ {indices, undefined, "indices", string, "Custom list of indices, as an Erlang term, followed by a dot. Example: '[{github,\"yrashk\"}].'"}
]}},
{"list",
{list,
"List packages on stdout",
[
{descriptions, $d, "descriptions", {boolean, false}, "Show package descriptions"},
{properties, $p, "properties", string, "Comma-separated list of properties to show"},
- {search, $s, "search", string, "Keyword to search"}
+ {search, $s, "search", string, "Keyword to search"},
+ {indices, undefined, "indices", string, "Custom list of indices, as an Erlang term, followed by a dot. Example: '[{github,\"yrashk\"}].'"}
]}},
{"search",
{search,
"Search packages",
[
{search, undefined, undefined, string, "Keyword to search"},
{descriptions, $d, "descriptions", {boolean, false}, "Show package descriptions"},
- {properties, $p, "properties", string, "Comma-separated list of properties to show"}
+ {properties, $p, "properties", string, "Comma-separated list of properties to show"},
+ {indices, undefined, "indices", string, "Custom list of indices, as an Erlang term, followed by a dot. Example: '[{github,\"yrashk\"}].'"}
]}},
{"fetch",
{fetch,
@@ -68,7 +72,8 @@ arg_proplist() ->
{addpath, $a, "add-path", {boolean, false}, "Add path to compiled package to .erlang"},
{install, $i, "install", {boolean, false}, "Install package (if install_command is available)"},
{spec, $s, "spec-file", string, "Use local specification file"},
- {quiet, $q, "quiet", {boolean, false}, "Don't render build/install scripts output"}
+ {quiet, $q, "quiet", {boolean, false}, "Don't render build/install scripts output"},
+ {indices, undefined, "indices", string, "Custom list of indices, as an Erlang term, followed by a dot. Example: '[{github,\"yrashk\"}].'"}
]}},
{"install",
{install,
@@ -79,7 +84,8 @@ arg_proplist() ->
{app, undefined, "app", string, "Fetch dependencies from .app"},
{spec, $s, "spec-file", string, "Use local specification file"},
{quiet, $q, "quiet", {boolean, false}, "Don't render build/install scripts output"},
- {nofetch, undefined, "no-fetch", {boolean, false}, "Don't (re)-fetch the source code"}
+ {nofetch, undefined, "no-fetch", {boolean, false}, "Don't (re)-fetch the source code"},
+ {indices, undefined, "indices", string, "Custom list of indices, as an Erlang term, followed by a dot. Example: '[{github,\"yrashk\"}].'"}
]}},
{"uninstall",
{uninstall,
@@ -109,7 +115,8 @@ arg_proplist() ->
{install, $i, "install", {boolean, false}, "Install package (if install_command is available)"},
{directory, undefined, undefined, string, "Directory to check package out to"},
{quiet, $q, "quiet", {boolean, false}, "Don't render build/install scripts output"},
- {nofetch, undefined, "no-fetch", {boolean, false}, "Don't (re)-fetch the source code"}
+ {nofetch, undefined, "no-fetch", {boolean, false}, "Don't (re)-fetch the source code"},
+ {indices, undefined, "indices", string, "Custom list of indices, as an Erlang term, followed by a dot. Example: '[{github,\"yrashk\"}].'"}
]}},
{"create",
{create,
@@ -162,6 +169,14 @@ main(Args) ->
case getopt:parse(OptSpec, ExtraArgs) of
{ok, {Opts, _}} ->
start(),
+ case proplists:get_value(indices, Opts) of
+ Indices when is_list(Indices) ->
+ {ok, Ts, _} = erl_scan:string(Indices),
+ {ok, IndicesTerm} = erl_parse:parse_term(Ts),
+ application:set_env(agner, indices, IndicesTerm);
+ _ ->
+ ignore
+ end,
Result = (catch handle_command(Command, Opts)),
Code =
case Result of

0 comments on commit a09e5c3

Please sign in to comment.