Skip to content

Commit

Permalink
Added -h/--homepage command line option for showing homepage in the b…
Browse files Browse the repository at this point in the history
…rowser
  • Loading branch information
yrashk committed Jan 27, 2011
1 parent 7e7089d commit 68c3040
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 5 additions & 1 deletion README.md
Expand Up @@ -65,7 +65,8 @@ Will list all agner-packages. With the `-d` or `--descriptions`
option, it will also print out the descriptions of the packages, for
easy grepping to find relevant packages.

agner spec PACKAGE [-v/--version package_version] [-b/--browser]
agner spec PACKAGE [-v/--version package_version] [-b/--browser]
[-h/--homepage]

Will print a specification of a given package on stdout. If the
optional version constraint is given (for example `agner spec gproc -v
Expand All @@ -75,6 +76,9 @@ optional version constraint is given (for example `agner spec gproc -v
If `-b` or `--browser` is used, it will also open browser with the specification
file in its respective `.agner` repository.

If `-h` or `--homepage` is present, it will also open browser with the package's
homepage.

agner fetch PACKAGE [DESTDIR] [-v/--version package_version]

Fetch a given `PACKAGE` to either the current directory or,
Expand Down
11 changes: 9 additions & 2 deletions src/agner.erl
Expand Up @@ -21,6 +21,7 @@ main(["spec"|Args]) ->
OptSpec = [
{package, undefined, undefined, string, "Package name"},
{browser, $b, "browser", boolean, "Show specification in the browser"},
{homepage, $h, "homepage", boolean, "Show package homepage in the browser"},
{version, $v, "version", {string, "@master"}, "Version"}
],
start(),
Expand All @@ -36,8 +37,14 @@ main(["spec"|Args]) ->
false ->
ignore
end,

io:format("~p~n",[spec(Package,Version)])
Spec = spec(Package,Version),
case proplists:get_value(homepage, Opts) of
true ->
agner_utils:launch_browser(proplists:get_value(homepage, Spec, "http://google.com/?q=" ++ Package));
false ->
ignore
end,
io:format("~p~n",[Spec])
end,
stop();

Expand Down

0 comments on commit 68c3040

Please sign in to comment.