amenzhinsky / dbus-codegen-go

D-Bus code-generation for golang
MIT License
17 stars 14 forks source link

First element of a list of input is skipped #5

Closed muka closed 4 years ago

muka commented 4 years ago

Hi, first of all great work! I am working on this repo thanks to your work https://github.com/muka/network_manager

I noticed that using a script like that

dbus-codegen-go -system=true -prefix=a.b.c -client-only -gofmt=true -package=network_manager < A.xml B.xml C.xml  > gen.go

The generated code will miss the initialization method and struct for the interface of the first file listed. As a workaround I am adding an empty file with just a <node /> as first of list and this work as a workaround.

You can test this behavior here by cloning the repo and running make generate. The AccessPoint interface will miss the NewNetworkManager_AccessPoint method and corresponding struct. Adding an empty node definition named a.xml fixes this

Thank you

amenzhinsky commented 4 years ago

Hi @muka , thanks for the appreciation.

It seems you're misusing the less sign:

% echo 1 > 1
% echo 2 > 2
% echo 3 > 3
% cat < 1 2 3
2
3

This happens because the content of 1 file is sent through stdin and 2 and 3 names are passed as command line arguments to the program that reads them out on it's own.

Short answer: you can omit < sign or combine output of multiple files before sending it to the generator <(cat a.xml b.xml c.xml)

muka commented 4 years ago

Oh sorry, my fault!

Thank you