#!/usr/bin/env escript
%% -*- erlang -*-
%%! debug verbose -noshell -pa ebin

main(["exists"|_Args]) ->
    [Path|_Rest] = _Args,
    [Object|_] = _Rest,
    Repo = geef:repository(Path),
    Odb = geef:repository_odb(Repo),
    Exists = geef:odb_exists(Odb, Object),
    io:format("Exists: ~w~n", [Exists]);
main([Command|_Args]) ->
    case Command of
      "h2r" ->
        [Object|_Rest] = _Args,
        Raw = geef:hex_to_raw(Object),
        io:format("Raw: ~w~n", [Raw]);
      "repo-path" ->
	[Path|_Rest] = _Args,
	Repo = geef:repository(Path),
	io:format("Repository path: ~s~n", [geef:repository_path(Repo)]);
      _Else ->
        usage()
    end;
main(_) ->
    usage().
        
usage() ->
    io:format("usage: ./geef h2r HEX_SHA\n"),
    halt(1).
        
