Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean running examples! #223

Closed
aadrian opened this issue Oct 30, 2017 · 9 comments
Closed

Clean running examples! #223

aadrian opened this issue Oct 30, 2017 · 9 comments

Comments

@aadrian
Copy link

aadrian commented Oct 30, 2017

Hi,

Would be nice to have some clean and running examples.

The existing ones seem "overloaded" and and mixed with unit tests :( .

Thank you.

@remkop
Copy link
Owner

remkop commented Oct 30, 2017

Good point. The manual contains mostly snippets to illustrate a point very briefly.
The Checksum example at the beginning of the manual is the only full running example.

If you have ideas for additional full examples that’d be great. They need to be fairly short though, about 20-25 lines of code or less.

@RobertZenz
Copy link
Contributor

Where should they go to? I think I could vamp up a few simple examples on the spot for at least basic usage. Ideally, they could be self-contained, runnable example files, like SimpleUsageMain.java somewhere in the source tree which contains everything needed including a main method to simply run it.

@aadrian
Copy link
Author

aadrian commented Oct 31, 2017

Where should they go to?

One possibility would be to have an /examples subdirectory/package, but that would require changing the build.gradle too.
Many other projects just use the multi-module features of Gradle but that also requires allot of changes.

Maybe a much simpler way would be to just make another GitHub repo: e.g. picocli-examples that would have:

dependencies {
    compile 'info.picocli:picocli:2.0.1'
    compile 'org.fusesource.jansi:jansi:1.16'
}

in build.gralde

Ideally, they could be self-contained,

Yes, but each example in it's own sub-directory? This way best practices could be better demonstrated (e.g. even if one example requires more than one file)

@remkop
Copy link
Owner

remkop commented Oct 31, 2017

I'd prefer to keep the examples in the same repo.

I'm open to other ideas but I was thinking to add an picocli.examples package under src/test/ (with subpackages if needed for elaborate examples). One nice thing is that the tests can have dependencies on other libraries, that may be useful for some examples.

Something like:

src/test/groovy/picocli/examples
src/test/java/picocli/examples

@RobertZenz
Copy link
Contributor

I'd also opt for the same repository. On a similar note, I wouldn't put the examples into the test directory, because, at least for me, I'd only expect "automated" tests in there not some form of documentation.

Maybe src/examples/java/Blah.java is an alternative? Or putting the examples directory directly under the root, to make it easily findable/visible?

@remkop
Copy link
Owner

remkop commented Oct 31, 2017

Yes that would work. Would be cleaner but just need to work out how the gradle build needs to change. Should be doable...

// assuming a picocli.examples package:
src/examples/java/picocli/examples/Blah.java
src/examples/groovy/picocli/examples/Blah.groovy

@remkop
Copy link
Owner

remkop commented Oct 31, 2017

Or we can have a separate module (in the same repo):

// main module (part of the distribution)
src/main/java
src/test/groovy
src/test/java

// separate module (not part of the distribution)
examples/src/main/java
examples/src/main/groovy

@RobertZenz
Copy link
Contributor

Either way sounds good to me, whatever is easier for you to manage (I'm not really into gradle).

@remkop remkop added this to the 2.1.0 milestone Nov 1, 2017
remkop added a commit that referenced this issue Nov 1, 2017
remkop added a commit that referenced this issue Nov 1, 2017
RobertZenz added a commit to RobertZenz/picocli that referenced this issue Nov 2, 2017
remkop added a commit that referenced this issue Nov 2, 2017
@remkop
Copy link
Owner

remkop commented Nov 6, 2017

User eprozium on Reddit requested subcommand examples.

If anyone has subcommand examples they would not mind contributing, all pull requests are welcome.

@remkop remkop modified the milestones: 2.1.0, 2.2.0 Nov 28, 2017
@remkop remkop removed this from the 3.0 milestone Dec 20, 2017
remkop added a commit that referenced this issue Oct 19, 2018
@remkop remkop closed this as completed May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants