function check_head(...)
    ok, branch = mtn_automate("get_option", "branch")	-- make sure we have a valid workspace
    ok, heads = mtn_automate("heads")
    if not ok then
      io.stderr:write("automate call failed\n")
      return
    end
    local arg = {...}
    arghead = arg[1]
    heads = heads:gsub("^%s*(.-)%s*$", "%1")	-- trim leading and trailing whitespace
    if (heads == arghead) then
        io.write("heads are equal\n")
    end
    io.write("end of command\n")
end


register_command("check_head", "", "Check that the heads of the branch are what is passed in",
      "This is a bogus command used to demonstrate user commands.", "check_head")


function diff_two_revs(rev_a, rev_b)
    ok, out = mtn_automate("content_diff", "-r", rev_a, "-r", rev_b)
    if not ok then
        io.stderr:write("automate call failed: " .. out .. "\n")
        return 1
    end
    io.stdout:write(out)
    return 0
end


register_command("diff_two_revs", "", "Outputs the differences between two revs",
      "This is a bogus command used to demonstrate user commands with options.", "diff_two_revs")

function get_default_command_options(command)
    local ret = {}
    if command[1] == "automate" and command[2] == "content_diff"
    then
        table.insert(ret, "--with-header")
    end
    return ret
end
