dlidstrom / Duplo

Duplicates finder for various source code formats.
GNU General Public License v2.0
97 stars 21 forks source link

added -cll option to allow user passing files through command line #10

Closed GreenCandlePrinter closed 8 years ago

GreenCandlePrinter commented 8 years ago

I've added a very basic support to select files from command line, I didn't wanted to modify the program structure a lot so I've just added a -cll option that will specify Duplo not to take the SourceFiles list from a file, but instead from the command line. Here is a usage example : ./duplo -cll xxx.h *.cpp out.list There would be better ways to handle this but still, it is working !

dlidstrom commented 8 years ago

Thanks Ange for trying to implement this. I'm not sure how you want -cll to be used though. Ideally I would like to specify the files to analyze using a wildcard or regular expression. Now that is a tricky thing to implement as it probably requires some platform-dependent API or library.

If Duplo is to support specifying the files on the command line then we shouldn't need to use the file at all. I think something like this would be great:

./duplo -include *.h,*.cpp

Do remember that Duplo is nice because of the minimal library dependencies (it mainly uses standard includes). It would be undesirable (IMO) to include 3rd party libraries (like Boost) because that would complicate the build on all platforms. I think this is the reason the original author(s) decided to specify the sources files list from a file. I won't merge this request as-is.

GreenCandlePrinter commented 8 years ago

Of course, it uses no specific third party libraries ! you can use it this way : ./duplo -cll *.cpp *.h out.list

dlidstrom commented 8 years ago

This is what I'm seeing (out.list does not exist in my folder and I shouldn't have to specify the file):

C:\Programming\Duplo-master>Duplo.exe -cll .cpp .h out.list Loading and hashing files ... Error: Can't open file: *.h. File doesn't exist or access denied. done.

Time: 0.004 seconds

C:\Programming\Duplo-master>

I didn't find any wildcard handling in your pull request.

GreenCandlePrinter commented 8 years ago

I'll check on windows why it is not working, then do another pull request

GreenCandlePrinter commented 8 years ago

It should work on both platforms now, the usage for -cll is now ./duplo -cll *.cpp *.h

dlidstrom commented 8 years ago

Great! I haven't had a chance to try this yet. Would it be possible to add an option to search recursively, so that we can eliminate the need for the source file completely? Also, would you mind documenting this in the Readme?

GreenCandlePrinter commented 8 years ago

I'll check this out later today !

GreenCandlePrinter commented 8 years ago

I think it could be possible to do it recursively, but if it's done, would you like me to remove the support for the source files list, so I can change the ̀Duplo constructor and make something more appropriate ?

dlidstrom commented 8 years ago

I think it is wise to keep the file alternative. Someone might want to include files in a way that is hard to do with wildcards. So if we can have both options would be best.

Would it be a good solution to add another constructor to Duplo that accepts the list of files? Or perhaps two static factory methods on the class and make the constructors private. I'll leave this for you to decide.

GreenCandlePrinter commented 8 years ago

I'll find out a solution ! Probably using a second constructor.

dlidstrom commented 8 years ago

Closing as there has been no progress in 4 months.