bbottema/simple-java-mail

Add CLI support

bbottema opened this issue ยท 9 comments

Simple Java Mail should Command Line Interface (CLI) support.

Considering the mantra that the builder API is the absolute single source of truth (including for documentation), CLI should be based on that. The CLI support should support all the API that require simple parameter values (String, ints, etc.) or values that can easily be converted (InetAddress is a no-go, but Email can be converted from EML string for example).

Considering the CLI should always reflect the builder API, it would be great if the CLI commands can be generated from the builder Java classes (using annotations).

Furthermore, the CLI support should support basic file/url handling. With the builder API that was the responsibility of the user (passing in DataSource instances for example, or byte arrays), but with the CLI that responsibility is moved back for basic support at least. This means the builder API needs to become even more robust than it is now, to accommodate CLI support comprehensively.

Solves #142.

I have a poc working in the "cli-support" branch, which uses picocli.

Currently working out some bugs/improvements with the picocli maintainer (issues are: remkop/picocli#430, remkop/picocli#433 and remkop/picocli#441), but it is progressing quite fast (thanks to @remkop).

After these issues have been resolved, I will flesh out the complete builder API in the CLI support.

There's a library out there that is able to include Javadoc at runtime, which would be a perfect match for the way CLI support is generated now from the builder API. Unfortunately, the library supports Java 8 and up, while Simple Java Mail is stuck at Java 7 (for good reasons).

Currently seeing if the library can be released for Java 7. Alternatively, I backport a fork to Java 7 and use that instead (if I can make the combination a success at all that is).

See dnault/therapi-runtime-javadoc#22.

To clarify why using this library would be a good idea: currently I'm maintaining dual documentation on each method: Javadoc and copied in annotations so I can use that documentation for the CLI --help displays. This library would allow me to maintain just the Javadoc.

Dear diary,

I helped backport the therapi-runtime-javadoc to Java 1.7 and the maintainer (@dnault) accepted it, which is great. Also helped solve a few bugs regarding parsing Javadoc that I encountered when using the library.

Currently I'm on a snapshot again, until my last changes are incorporated. I have good faith that @dnault will merge and release in due time. I'm in no hurry though, since I'm still working on the CLI feature as a whole.

All in all looking pretty solid.

CLI support is shaping up nicely, it's mostly done and all therapi-javadoc issues have been released properly as well. Now working on making CLI support an optional dependency, which is implemented moving to a modular project approach (#183).

Cli support is done, documentation is done. Currently working on the last problem where ANSI color support isn't detected properly by Picocli (remkop/picocli#581).

Finally, CLI support is finished! I'll finish the documentation and then move on ๐ŸŽ‰

Finally released in 6.0.0-rc1!!

6.0.0 has released as well, finally.

Congrats! ๐ŸŽ† ๐ŸŽ‰