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

Make pony programs exit on an unrecognized pony runtime option #4622

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dipinhora
Copy link
Contributor

Prior to this commit, if someone passed an unrecognized pony runtime option (due to a typo or otherwise), the pony program would silently ignore the argument and keep running without the operator knowing that the intended pony runtime option wasn't applied.

root@5babe01f566f:/workspaces/ponyc# ./helloworld --ponyblah
Hello, world.
root@5babe01f566f:/workspaces/ponyc#

This commit changes things so that pony programs will now print out an error message and exit with a non-zero exit code when an unrecognized pony runtime option is supplied:

root@5babe01f566f:/workspaces/ponyc# ./helloworld --ponyblah
./helloworld: Unrecognised pony runtime option: '--ponyblah'!
Run './helloworld --ponyhelp' for available pony runtime options.
root@5babe01f566f:/workspaces/ponyc#

@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Feb 20, 2025
@SeanTAllen SeanTAllen added the changelog - added Automatically add "Added" CHANGELOG entry on merge label Feb 20, 2025
@ponylang-main
Copy link
Contributor

Hi @dipinhora,

The changelog - added label was added to this pull request; all PRs with a changelog label need to have release notes included as part of the PR. If you haven't added release notes already, please do.

Release notes are added by creating a uniquely named file in the .release-notes directory. We suggest you call the file 4622.md to match the number of this pull request.

The basic format of the release notes (using markdown) should be:

## Title

End user description of changes, why it's important,
problems it solves etc.

If a breaking change, make sure to include 1 or more
examples what code would look like prior to this change
and how to update it to work after this change.

Thanks.

@SeanTAllen
Copy link
Member

As the tests indicate, this will break things. Any program that uses a CLI that starts with --pony is going to get whacked like the full test program runner as an example. I think the intent of this is good, but I don't think that claiming every flag that starts with "pony" as being "runtime only" is a good idea.

@dipinhora
Copy link
Contributor Author

As the tests indicate, this will break things. Any program that uses a CLI that starts with --pony is going to get whacked like the full test program runner as an example. I think the intent of this is good, but I don't think that claiming every flag that starts with "pony" as being "runtime only" is a good idea.

fair enough.. although the current situation seems like a recipe for disaster where a new pony runtime option might get added that silently takes precedence over an existing option in a pony program..

@dipinhora dipinhora closed this Feb 20, 2025
@ponylang-main ponylang-main removed the discuss during sync Should be discussed during an upcoming sync label Feb 20, 2025
@SeanTAllen
Copy link
Member

@dipinhora agreed, that is also a problem. I think it is worth a discussion so I am reopening and it can be gone over at the next sync.

@SeanTAllen SeanTAllen reopened this Feb 20, 2025
@SeanTAllen SeanTAllen added discuss during sync Should be discussed during an upcoming sync changelog - changed Automatically add "Changed" CHANGELOG entry on merge and removed changelog - added Automatically add "Added" CHANGELOG entry on merge labels Feb 20, 2025
@SeanTAllen
Copy link
Member

@dipinhora can you rebase this against main?

@SeanTAllen
Copy link
Member

SeanTAllen commented Feb 23, 2025

If we decide we want to reserve all of --pony* then I think as part of this PR, we should note the reservation as part of the CLI package. As @jemc points out, Env.args should have similar documentation.

@SeanTAllen
Copy link
Member

When this is rebased against main, the CI should be successful.

@SeanTAllen
Copy link
Member

Consensus on the sync call is in favor of this @dipinhora. Please proceed.

Prior to this commit, if someone passed an unrecognized pony runtime
option (due to a typo or otherwise), the pony program would silently
ignore the argument and keep running without the operator knowing
that the intended pony runtime option wasn't applied.

```
root@5babe01f566f:/workspaces/ponyc# ./helloworld --ponyblah
Hello, world.
root@5babe01f566f:/workspaces/ponyc#
```

This commit changes things so that pony programs will now print out
an error message and exit with a non-zero exit code when an
unrecognized pony runtime option is supplied:

```
root@5babe01f566f:/workspaces/ponyc# ./helloworld --ponyblah
./helloworld: Unrecognised pony runtime option: '--ponyblah'!
Run './helloworld --ponyhelp' for available pony runtime options.
root@5babe01f566f:/workspaces/ponyc#
```
@dipinhora
Copy link
Contributor Author

@dipinhora can you rebase this against main?

rebased..

If we decide we want to reserve all of --pony* then I think as part of this PR, we should note the reservation as part of the CLI package. As @jemc points out, Env.args should have similar documentation.

can you folks please suggest the wording desired? also, i'm not familiar with the cli package.. where in the cli package should the note be added?

@SeanTAllen
Copy link
Member

SeanTAllen commented Feb 25, 2025

I looked at the CLI docs and I don't think there is a good place for a note there. Certainly nothing that I can see adding value. I think it is reasonable for us to reconsider.

Given that all new usage of flags will result in an error when someone tries to use then perhaps the correct place is part of the error message that Dipin has added here. "If you tried to add a flag starting with --pony ... etc etc".

I think that having in that error message rather than tucked away in CLI and Env docs will result in a better experience for anything tripping over --pony* being reserved for the runtime.

And in addition to that, we have the release notes to make the breaking change clear in the case of existing programs that might break.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog - changed Automatically add "Changed" CHANGELOG entry on merge discuss during sync Should be discussed during an upcoming sync
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants