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

add cli commons to factor out common parsing code #7301

Merged
merged 2 commits into from
Oct 30, 2021
Merged

Conversation

cgardens
Copy link
Contributor

@cgardens cgardens commented Oct 23, 2021

What

  • With Cloud we are leaning towards writing more scripts in java. We currently use apache.commons.cli for this. While I recommend in this issue we move away from it (and use picocli instead), this PR adds a couple quick helpers to factor out common logic we use for parsing command line args with the current tool. It also helps concentrate all of the use of the cli tool, so it'll be easier to excise.
  • Once it is released, I'll switch cloud to depend on it.

Copy link
Contributor

@sherifnada sherifnada left a comment

Choose a reason for hiding this comment

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

unit tests and a question but otherwise LGTM

@@ -0,0 +1,7 @@
plugins {
Copy link
Contributor

Choose a reason for hiding this comment

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

is it overkill to add a README for this module describing it's purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lol. i guess if you have to ask it's not overkill :D I'll add it.

void testGetTaggedImageName() {
final String repository = "airbyte/repo";
final String tag = "12.3";
assertEquals("airbyte/repo:12.3", Clis.getTaggedImageName(repository, tag));
Copy link
Contributor

Choose a reason for hiding this comment

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

where is this method defined? am I being thick? it's not in Clis.java

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not thick. i fix.

import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;

public class Clis {
Copy link
Contributor

Choose a reason for hiding this comment

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

we should probably have at least one test for each public method in this class

Copy link
Contributor

@benmoriceau benmoriceau left a comment

Choose a reason for hiding this comment

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

LGTM, just a small comment on the use of an enum.

}
default -> throw new IllegalStateException("Unexpected value: " + command);
}

final CommandLine parsed = runParse(options, args, command);
final CommandLine parsed = Clis.parse(args, options, command.toString().toLowerCase());
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the command enum is not used here and we use string instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's the trade off of DRYing this is that the common parse function can't really reasonably know about the enum, right?

@cgardens cgardens temporarily deployed to more-secrets October 30, 2021 01:12 Inactive
@cgardens cgardens merged commit 58902f3 into master Oct 30, 2021
@cgardens cgardens deleted the cgardens/arg_parse branch October 30, 2021 01:44
schlattk pushed a commit to schlattk/airbyte that referenced this pull request Jan 4, 2022
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.

None yet

3 participants