๐ Learning and exploring picocli.
picocli - a mighty tiny command line interface
Follow the below instructions to build and run the program.
- Use Java 17
- Build the program and run the tests:
./gradlew test
- Build and run the program with the required and optional command-line arguments:
./gradlew cli:run --args ".. --depth 0"
- Next, try another directory:
- For example, I place my own repositories in
~/repos/personal
. So, I can use the CLI to search for Gradle projects in that directory with the following command. ./gradlew cli:run --args "$HOME/repos/personal --depth 1"
- For example, I place my own repositories in
Tip: follow the below instructions to install the CLI on the system.
- Build the program distribution
./gradlew cli:installDist
- Symlink the launcher script to somewhere on the
PATH
ln -sf "$PWD/cli/build/install/cli/bin/cli" /usr/local/bin/detect-gradle
- Run it!
detect-gradle
- Change directories. Run it from anywhere!
cd ~/repos; detect-gradle . --depth 2
General clean-ups, TODOs and things I wish to implement for this project:
- DONE Integrate picocli
- DONE By default, use the current directory as the search directory
- ABANDONED (see the 'codegen' branch) Use picocli's code-gen. I am generally skeptical of using code gen in projects of significance but I'm happy to learn it, especially because picocli recommends it.
- Generate auto completion scripts
- DONE Include instructions to install the CLI
- Implement CLI help output (e.g. the
--help
option output) - DONE Implement something at least vaguely useful, like "detect a Gradle project" and take options for "how many levels deep to check in the directory structure (depth)"