Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 25, 2025

This PR implements a complete action execution system for jpm that allows users to define and execute custom commands through the app.yml file. The system includes comprehensive documentation, cross-platform compatibility, and extensive test coverage.

Key Features

Action Execution System

  • jpm do command: Execute actions defined in app.yml with optional --list/-l flag to show available actions
  • Alias commands: Direct execution via jpm build, jpm run, jpm test, jpm clean
  • Argument pass-through: All alias commands accept additional arguments that are passed unchanged to the underlying action
  • Performance optimization: Classpath resolution only occurs when {{deps}} variable is present in the action command

Variable Substitution

  • {{deps}}: Replaced with full classpath of all dependencies
  • {/}: Cross-platform file separator (\ on Windows, / on Unix)
  • {:}: Cross-platform path separator (; on Windows, : on Unix)
  • {./path} and {~/path}: Platform-specific path conversion for relative and home directory paths

Cross-Platform Support

  • Windows and Linux CI testing via GitHub Actions matrix
  • Platform-specific command execution (cmd.exe on Windows, /bin/sh on Unix)
  • Proper path handling and conversion across operating systems

Comprehensive Test Suite

  • 31 tests covering all action execution features using AssertJ fluent assertions
  • Integration tests for CLI commands and argument handling
  • Performance optimization validation
  • Cross-platform compatibility testing
  • Error handling and edge case coverage

Documentation

  • Added comprehensive "Actions" section to README.md explaining:
    • How to define actions in app.yml
    • Variable substitution features with examples
    • Cross-platform usage patterns
    • Performance considerations

Example Usage

# app.yml
dependencies:
  com.github.lalyos:jfiglet:0.0.9

actions:
  build: "javac -cp {{deps}} *.java"
  run: "java -cp {{deps}} HelloWorld"
  test: "java -cp {{deps}} TestRunner"
  clean: "rm -f *.class"
# Execute actions
jpm do build           # Execute build action
jpm run --verbose      # Execute run action with arguments
jpm do --list          # List all available actions

# Cross-platform example
jpm do build-cross: "javac -cp {{deps}}{:}{./target/classes} src{/}*.java"

The implementation follows jpm's established architecture pattern with business logic in Jpm.java and UI handling in Main.java, ensuring consistency with existing commands.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copy link
Contributor Author

Copilot AI commented Aug 25, 2025

@quintesse 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Copilot AI and others added 3 commits August 25, 2025 09:02
Co-authored-by: quintesse <778793+quintesse@users.noreply.github.com>
Co-authored-by: quintesse <778793+quintesse@users.noreply.github.com>
Co-authored-by: quintesse <778793+quintesse@users.noreply.github.com>
Copilot AI changed the title [WIP] Minimalist run option? Implement minimalist run option for user-defined commands Aug 25, 2025
Copilot AI requested a review from quintesse August 25, 2025 09:13
…hange ${path} to ${deps}

Co-authored-by: quintesse <778793+quintesse@users.noreply.github.com>
Copilot AI changed the title Implement minimalist run option for user-defined commands Implement minimalist action execution for user-defined commands Aug 25, 2025
Copilot AI requested a review from quintesse August 25, 2025 10:16
Copy link
Contributor

@quintesse quintesse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot the code doesn't compile, I think you haven't taken into account the instructions from copilot-instructions.md where it explains you need to run ./mvnw spotless:apply on the code before committing.

// Handle common aliases
if (args.length > 0) {
String firstArg = args[0];
if ("compile".equals(firstArg) || "test".equals(firstArg) || "run".equals(firstArg)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot please change "compile" to "build"

@quintesse
Copy link
Contributor

@copilot the code doesn't compile, I think you haven't taken into account the instructions from copilot-instructions.md where it explains you need to run ./mvnw spotless:apply on the code before committing. Please rebase the PR on main first to pull in the copilot-instructions.md file.

Copy link
Contributor Author

Copilot AI commented Aug 25, 2025

@copilot the code doesn't compile, I think you haven't taken into account the instructions from copilot-instructions.md where it explains you need to run ./mvnw spotless:apply on the code before comm...

Fixed! I've rebased the PR on main to get the copilot-instructions.md file and ran ./mvnw spotless:apply to format the code. I also addressed the request to change "compile" to "build" in the alias handling. The code now compiles successfully and passes all formatting checks. See commit f4533dd.

@quintesse
Copy link
Contributor

@copilot please add an optional --list/-l flag to "do" that lists all available actions

@quintesse
Copy link
Contributor

@copilot the problem with your solution is that it doesn't retain the ordering of the arguments (see updated test testDoAliasWithArgs that now fails)

…tation

Co-authored-by: quintesse <778793+quintesse@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 27, 2025

@copilot the problem with your solution is that it doesn't retain the ordering of the arguments (see updated test testDoAliasWithArgs that now fails)

Fixed! The issue was that PicoCLI's @Parameters and @Unmatched annotations process arguments separately, causing the ordering to be lost. I've updated the implementation to use only @Unmatched to capture all arguments, which preserves the original command-line ordering. The test now passes and jpm run --foo bar correctly passes arguments in the order --foo bar instead of bar --foo. See commit ec07563.

Copilot AI changed the title Implement action execution system with comprehensive test suite, cross-platform CI, {{deps}} variable substitution, and unknown option pass-through Implement action execution system with comprehensive test suite, cross-platform CI, {{deps}} variable substitution, and argument ordering preservation Aug 27, 2025
@quintesse
Copy link
Contributor

@copilot could you update all the tests to use jassert?

…st files

Co-authored-by: quintesse <778793+quintesse@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 27, 2025

@copilot could you update all the tests to use jassert?

Updated all tests to use AssertJ fluent assertions. Added AssertJ 3.26.3 as a test dependency and converted all JUnit assertions (assertEquals, assertTrue, assertNull, etc.) to the more readable and expressive AssertJ syntax (assertThat().isEqualTo(), assertThat().isTrue(), etc.). All 28 tests continue to pass. See commit 63c13a3.

@quintesse
Copy link
Contributor

@copilot can you add a section called "Actions" to the README, just before the "Installation" section, that explains the new features? (meaning the "do" command, what is needed in the app.yml file, the special replacement features and alias commands like build and run)

… variable substitution features

Co-authored-by: quintesse <778793+quintesse@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 28, 2025

@copilot can you add a section called "Actions" to the README, just before the "Installation" section, that explains the new features? (meaning the "do" command, what is needed in the app.yml file, th...

Added comprehensive "Actions" section to README.md before the "Installation" section explaining the new action execution features. The section covers:

  • How to define actions in app.yml
  • The jpm do command and alias commands (build, run, test, clean)
  • Variable substitution features ({{deps}}, {/}, {:}, {./...}, {~/...})
  • Cross-platform compatibility examples
  • Performance optimization details

See commit 3a298b8.

Copilot AI changed the title Implement action execution system with comprehensive test suite, cross-platform CI, {{deps}} variable substitution, and argument ordering preservation Implement action execution system with comprehensive test suite, cross-platform CI, {{deps}} variable substitution, argument ordering preservation, and documentation Aug 28, 2025
@quintesse quintesse marked this pull request as ready for review August 28, 2025 12:29
@quintesse quintesse merged commit a1b6cff into main Aug 28, 2025
2 checks passed
@quintesse quintesse deleted the copilot/fix-43 branch August 28, 2025 12:34
@quintesse quintesse changed the title Implement action execution system with comprehensive test suite, cross-platform CI, {{deps}} variable substitution, argument ordering preservation, and documentation Implement action execution system with variable substitution and documentation Aug 29, 2025
@quintesse quintesse mentioned this pull request Aug 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants