airlift / airline

Java annotation-based framework for parsing Git like command line structures
Apache License 2.0
846 stars 141 forks source link

Dependency on guava #40

Open dkandalov opened 9 years ago

dkandalov commented 9 years ago

Thanks a lot for the library. Surprisingly there aren't many java CLI libraries designed for usage for commands with parameters. IMHO this is the best one.

The only disadvantage I found is dependency on guava:

Do you think it makes sense to copy into project only those guava bits which are used? I could do this myself, just wanted to ask your opinion.

Novanic commented 8 years ago

Hi,

I tried out your library and I think it is very smart. I need it also to support various commands in combination with parameters/arguments.

I just tried to get rid off guava and the most of it can be replaced with methods of the JDK or a few, small, simple util methods. I think it is also not notable less efficient. There are some lambda-style functional method usages remaining which could get replaced with Lambdas of Java 8. What is your plan to upgrade to Java 8?

Novanic commented 8 years ago

I think it would be good to replace guava with an upgrade to Java 8. The upgrade to Java 8 is definitely useful in the future (Java 7 will reach end of life). The point in time is just unclear, regarding the airline library. :-)

Here an example of a replacement of guava with Lambdas of Java 8. I'm just preparing a patch without guava.

Before (guava): options = CollectionUtils.asList(transform(metadataIndex.values(), new Function<Collection, OptionMetadata>() { @Override public OptionMetadata apply(@Nullable Collection options) { return new OptionMetadata(options); } }));

After (Java 8, Lambda); options = metadataIndex.values().stream().map(OptionMetadata::new).collect(Collectors.toList());

martint commented 8 years ago

We've started migrating other airlift-related projects to Java 8 already, but haven't got to this one, yet. We're moving in that direction, though, so thanks for working on that patch.

Novanic commented 8 years ago

Ok, sounds good. I have now created a fork/branch which is working with Java 8 and without guava. The fork can be found here: https://github.com/Novanic/airline

I would be happy, when it could get integrated/pushed to the master. :-) There is one optimization/refactoring within the Parser class left. There is still a very intransparent iterator handling within this class. I try to get this optimized tomorrow or by next week.