   end
 
   def generate(proto_path, out_path, opts) do
-    IO.inspect opts
     proto = parse_proto(proto_path)
-    assigns = [top_mod: top_mod(proto.package), proto_content: proto_content(proto_path, opts),
+    assigns = [top_mod: top_mod(proto.package, proto_path, opts), proto_content: proto_content(proto_path, opts),
                proto: proto, proto_path: proto_path(proto_path, out_path, opts),
                use_proto_path: opts[:use_proto_path], service_prefix: service_prefix(proto.package) ]
     create_file file_path(proto_path, out_path), grpc_gen_template(assigns)


  def parse_proto(proto_path) do
    parsed = Protobuf.Parser.parse_files!([proto_path])
    proto = %Proto{}
    services = []
    proto = Enum.reduce parsed, proto, fn(item, proto) ->
      case item do
        {:package, package} ->
          %{proto | package: to_string(package)}

          rpcs = Enum.map(rpcs, fn(rpc) -> Tuple.delete_at(rpc, 0) end)
          service_name = service_name |> to_string |> camelize
          service = %Proto.Service{name: service_name , rpcs: rpcs}
          %{proto | services: [service|proto.services]}
        _ -> proto
      end
    end
    %{proto | services: Enum.reverse(proto.services)}
  end

  def top_mod(package, proto_path, opts) do
    package = opts[:namespace] || package || Path.basename(proto_path, ".proto")
    package
    |> to_string
    |> String.split(".")
