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

Refactor CLI argument parsing #467

Closed

Conversation

grodin
Copy link

@grodin grodin commented May 17, 2024

Working towards #391.

I wanted to open this to get feedback on the approach.

I could have chosen to use exceptions, but I find sealed classes much more composable and I already anticipate adding another class to the ParseResult hierarchy to represent a situation where a message needs to be shown to the user but isn't an error (--help is the obvious example).

Closes #465 more or less as a side-effect.

@facebook-github-bot
Copy link
Contributor

Hi @grodin!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@grodin
Copy link
Author

grodin commented May 17, 2024

Forgot to sign the CLA before opening this, done now

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 17, 2024
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

Copy link
Contributor

@hick209 hick209 left a comment

Choose a reason for hiding this comment

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

I overall loved the direction things are going, keep it up! 👍

Just a few minor comments, but nothing serious. Let me know if you want to push this already and proceed with another PR or just build on top of this one.

core/src/main/java/com/facebook/ktfmt/cli/Main.kt Outdated Show resolved Hide resolved
core/src/main/java/com/facebook/ktfmt/cli/Main.kt Outdated Show resolved Hide resolved
Joseph Cooper added 2 commits May 20, 2024 16:50
Intended to make testing of combination of CLI parameters easier
@grodin
Copy link
Author

grodin commented May 20, 2024

I overall loved the direction things are going, keep it up! 👍

Just a few minor comments, but nothing serious. Let me know if you want to push this already and proceed with another PR or just build on top of this one.

I overall loved the direction things are going, keep it up! 👍

Just a few minor comments, but nothing serious. Let me know if you want to push this already and proceed with another PR or just build on top of this one.

Probably worth separating them out into separate PRs. I've got some more nearly ready once this is merged.

Some of this is formatted with ktfmt, some isn't, but you said you'd handle that when you merge it internally, so I'll leave that to you.

Copy link
Contributor

@hick209 hick209 left a comment

Choose a reason for hiding this comment

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

image

So far so good to me. Let me know when this is ready and I'll import it for internal review (last step before we merge in)

@@ -173,4 +178,11 @@ class Main(
throw e
}
}

fun exitFatal(message: String, returnCode: Int): Nothing {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason this is not private?

Copy link
Author

Choose a reason for hiding this comment

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

Nope! Glad you caught that actually, it's part of some refactoring I haven't finished

@hick209
Copy link
Contributor

hick209 commented Jun 3, 2024

In case you are not going to work on it this week, let's start merging this already, you could make other changes in other PRs.

@facebook-github-bot
Copy link
Contributor

@hick209 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@grodin
Copy link
Author

grodin commented Jun 4, 2024

In case you are not going to work on it this week, let's start merging this already, you could make other changes in other PRs.

Sorry, had a very busy period at home and on top of that, drive failure in my laptop, so I've not been able to work on this much. I am still very much intending to get more done on ktfmt, hopefully end of this week, definitely more next.

@hick209
Copy link
Contributor

hick209 commented Jun 5, 2024

No problem @grodin, I completely understand.
I went ahead and did some modifications to it and will merge this PR now. Feel free to submit some more 😃

Thanks a ton for your contributions, we're really grateful for that.

@facebook-github-bot
Copy link
Contributor

@hick209 merged this pull request in 26a24ae.

github-merge-queue bot pushed a commit to slackhq/circuit that referenced this pull request Jun 7, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [com.facebook:ktfmt](https://togithub.com/facebook/ktfmt) |
dependencies | minor | `0.49` -> `0.50` |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>facebook/ktfmt (com.facebook:ktfmt)</summary>

### [`v0.50`](https://togithub.com/facebook/ktfmt/releases/tag/v0.50):
0.50

#### Changelog

- Add pre commit hooks to readme
([facebook/ktfmt#462)
– [@&#8203;0x26res](https://togithub.com/0x26res)
- Add homebrew installation note to readme
([facebook/ktfmt#468)
– [@&#8203;chenrui333](https://togithub.com/chenrui333)
- Refactor CLI argument parsing
([facebook/ktfmt#467)
– [@&#8203;grodin](https://togithub.com/grodin)
- Fix issue with context receive in lambdas
([facebook/ktfmt#471)
– [@&#8203;hick209](https://togithub.com/hick209)
- Don't reorder [@&#8203;sample](https://togithub.com/sample) tag
([facebook/ktfmt#406)
– [@&#8203;davidtorosyan](https://togithub.com/davidtorosyan)

**Full Changelog**:
facebook/ktfmt@v0.49...v0.50

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://togithub.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zOTYuMSIsInVwZGF0ZWRJblZlciI6IjM3LjM5Ni4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
slack-oss-bot added a commit to slackhq/slack-gradle-plugin that referenced this pull request Jun 10, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [com.facebook:ktfmt](https://togithub.com/facebookincubator/ktfmt) |
dependencies | minor | `0.49` -> `0.50` |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>facebookincubator/ktfmt (com.facebook:ktfmt)</summary>

### [`v0.50`](https://togithub.com/facebook/ktfmt/releases/tag/v0.50):
0.50

#### Changelog

- Add pre commit hooks to readme
([facebook/ktfmt#462)
– [@&#8203;0x26res](https://togithub.com/0x26res)
- Add homebrew installation note to readme
([facebook/ktfmt#468)
– [@&#8203;chenrui333](https://togithub.com/chenrui333)
- Refactor CLI argument parsing
([facebook/ktfmt#467)
– [@&#8203;grodin](https://togithub.com/grodin)
- Fix issue with context receive in lambdas
([facebook/ktfmt#471)
– [@&#8203;hick209](https://togithub.com/hick209)
- Don't reorder [@&#8203;sample](https://togithub.com/sample) tag
([facebook/ktfmt#406)
– [@&#8203;davidtorosyan](https://togithub.com/davidtorosyan)

**Full Changelog**:
facebook/ktfmt@v0.49...v0.50

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://togithub.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zOTYuMSIsInVwZGF0ZWRJblZlciI6IjM3LjM5Ni4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
ZacSweers pushed a commit to ZacSweers/CatchUp that referenced this pull request Jun 14, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [com.facebook:ktfmt](https://togithub.com/facebook/ktfmt) | `0.49` ->
`0.51` |
[![age](https://developer.mend.io/api/mc/badges/age/maven/com.facebook:ktfmt/0.51?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/com.facebook:ktfmt/0.51?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/com.facebook:ktfmt/0.49/0.51?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/com.facebook:ktfmt/0.49/0.51?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>facebook/ktfmt (com.facebook:ktfmt)</summary>

###
[`v0.51`](https://togithub.com/facebook/ktfmt/blob/HEAD/CHANGELOG.md#051)

##### Added

-   Created CHANGELOG.md
- Added --help option to CLI
([facebook/ktfmt#477)

##### Changed

- Preserves blank spaces between when clauses
([facebook/ktfmt#342)
-   Named the default style as `Formatter.META_FORMAT` / `--meta-style`
-   `FormattingOptions` constructor parameters order was changed

##### Fixed

- Compilation issues with online formatter
(facebook/ktfmt@8605080)
- Removing valid semicolons
([facebook/ktfmt#459)
- Incorrect detection of unused `assign` import
([facebook/ktfmt#411)

##### Removed

- **Deleted `Formatter.DROPBOX_FORMAT` / `--dropbox-style` (BREAKING
CHANGE)**
-   Deleted `FormattingOptions.Style` enum

### [`v0.50`](https://togithub.com/facebook/ktfmt/releases/tag/v0.50):
0.50

#### Changelog

- Add pre commit hooks to readme
([facebook/ktfmt#462)
– [@&#8203;0x26res](https://togithub.com/0x26res)
- Add homebrew installation note to readme
([facebook/ktfmt#468)
– [@&#8203;chenrui333](https://togithub.com/chenrui333)
- Refactor CLI argument parsing
([facebook/ktfmt#467)
– [@&#8203;grodin](https://togithub.com/grodin)
- Fix issue with context receive in lambdas
([facebook/ktfmt#471)
– [@&#8203;hick209](https://togithub.com/hick209)
- Don't reorder [@&#8203;sample](https://togithub.com/sample) tag
([facebook/ktfmt#406)
– [@&#8203;davidtorosyan](https://togithub.com/davidtorosyan)

**Full Changelog**:
facebook/ktfmt@v0.49...v0.50

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/ZacSweers/CatchUp).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zOTMuMCIsInVwZGF0ZWRJblZlciI6IjM3LjM5My4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Misspelled flags in CLI can cause user data loss
3 participants