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

Improved CLI argument handling using picocli #1534

Merged
merged 31 commits into from
Mar 3, 2023
Merged

Improved CLI argument handling using picocli #1534

merged 31 commits into from
Mar 3, 2023

Conversation

patilatharva
Copy link
Collaborator

@patilatharva patilatharva commented Jan 10, 2023

Objective

Use Picocli instead of Apache Commons CLI to parse command line options and parameters in Lfc.java, Lff.java and CliBase.java.

Reason

Migrating from Commons CLI to picocli

Tasks:

  • Refactor CliBase.java to implement the Runnable interface, to support Picocli.
  • Remove runMain in CliBase.java because Picocli handles simple validation and --help/--version options.
  • Declare options as annotated fields and remove the CLIOption enum (Lfc.java/Lff.java).
  • Implement the run() method as an entry point to post-argument parsing execution, in accordance with the Runnable interface (Lfc.java/Lff.java).
  • Rewrite function filterProps into a new function filterPassOnProps to create code gen properties from Picocli options (CliBase.java).
  • Refactoring for clarity: split runTool into runTool + invokeGenerator in Lfc.java, and runTool into runTool + formatAllFiles in Lff.java.
  • Tweak CLI tests to support Picocli output syntax (e.g. "Unrecognized option" → "Unknown option").
  • Ensure all tests on CI are passing.

…mporary class CliBaseNew.java to support the changes.
@patilatharva patilatharva self-assigned this Jan 10, 2023
@patilatharva patilatharva linked an issue Jan 10, 2023 that may be closed by this pull request
@patilatharva patilatharva changed the title Apache Commons CLI to Picocli migration for Lfc and Lff. Replacing Apache Commons CLI with Picocli for Lfc and Lff. Jan 10, 2023
Copy link
Collaborator

@cmnrd cmnrd left a comment

Choose a reason for hiding this comment

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

This looks really great! Thanks for taking care of this refactoring. I left a few minor comments directly on the code.

org.lflang/src/org/lflang/cli/Lfc.java Outdated Show resolved Hide resolved
org.lflang/src/org/lflang/cli/Lfc.java Outdated Show resolved Hide resolved
org.lflang/src/org/lflang/cli/Lfc.java Outdated Show resolved Hide resolved
@lhstrh
Copy link
Member

lhstrh commented Jan 12, 2023

Just resolved conflicts to trigger a CI run. Please check if I did it correctly :-)

Copy link
Member

@lhstrh lhstrh left a comment

Choose a reason for hiding this comment

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

This looks great, @patilatharva! I understood that you had started working on unit tests. Is that coming along or do you need help with those?

@lhstrh
Copy link
Member

lhstrh commented Jan 12, 2023

There are some strange test failures that are popping up, so this definitely needs some more work.

You can ignore the build failure in Maven for now. Either I'll push a fix for that or we punt on it and wait until the Maven build support gets removed from this repository (we only need it to build Epoch, which will soon be hosted in its own repo).

@patilatharva
Copy link
Collaborator Author

Just resolved conflicts to trigger a CI run. Please check if I did it correctly :-)

Thanks, looks good to me!

There are some strange test failures that are popping up, so this definitely needs some more work.

Definitely, looking into it now.

org.lflang/src/org/lflang/cli/CliBase.java Show resolved Hide resolved
org.lflang/src/org/lflang/cli/Lfc.java Outdated Show resolved Hide resolved
org.lflang/src/org/lflang/cli/Lfc.java Outdated Show resolved Hide resolved
Copy link
Member

@tanneberger tanneberger left a comment

Choose a reason for hiding this comment

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

Looks good to me

@lhstrh lhstrh changed the title Replacing Apache Commons CLI with Picocli for Lfc and Lff. Improved CLI argument handling using picocli Mar 2, 2023
@lhstrh lhstrh requested a review from cmnrd March 2, 2023 02:26
Copy link
Collaborator

@cmnrd cmnrd left a comment

Choose a reason for hiding this comment

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

This looks like a great improvement. I added a couple of comments, mostly small things. I hope we can resolve them quickly and merge this soon!

org.lflang/src/org/lflang/cli/CliBase.java Outdated Show resolved Hide resolved
org.lflang/src/org/lflang/cli/CliBase.java Show resolved Hide resolved
org.lflang/src/org/lflang/cli/CliBase.java Outdated Show resolved Hide resolved
org.lflang/src/org/lflang/cli/Lfc.java Outdated Show resolved Hide resolved
org.lflang/src/org/lflang/cli/Lfc.java Show resolved Hide resolved
org.lflang/src/org/lflang/cli/Lfc.java Outdated Show resolved Hide resolved
org.lflang/src/org/lflang/cli/Lff.java Outdated Show resolved Hide resolved
Copy link
Collaborator

@cmnrd cmnrd left a comment

Choose a reason for hiding this comment

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

Updating review status to "request changes".

Copy link
Collaborator

@cmnrd cmnrd left a comment

Choose a reason for hiding this comment

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

Thanks for your quick fixes! This is ready to be merged as far as I am concerned.

@cmnrd cmnrd added this to the 0.5.0 milestone Mar 2, 2023
Copy link
Member

@lhstrh lhstrh left a comment

Choose a reason for hiding this comment

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

Please address the version TODO and once fixed we can merge this. Thanks, @patilatharva!

@lhstrh lhstrh merged commit c16bedf into master Mar 3, 2023
@lhstrh lhstrh deleted the picocli branch March 3, 2023 07:28
@oowekyala oowekyala mentioned this pull request May 2, 2023
@petervdonovan petervdonovan added the refactoring Code quality enhancement label Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Code quality enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace Apache commons CLI
6 participants