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

feat: bare lake init & validated pkg names #2890

Merged
merged 1 commit into from
Nov 16, 2023

Conversation

tydeu
Copy link
Member

@tydeu tydeu commented Nov 16, 2023

Closes #2637.

As a new feature, lake init . or a bare lake init will now create a package with the current directory's name.

Will also validate that a package name:

  • Is not one of Init, Lean, Lake, or Main (case-insensitive)
  • Is not all . or all whitespace
  • Does not contain / or \.

@tydeu tydeu changed the base branch from nightly to master November 16, 2023 01:44
@tydeu tydeu force-pushed the lake/init-pkg-names branch from f78b7f1 to 2cb12ec Compare November 16, 2023 01:45
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Nov 16, 2023
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Nov 16, 2023
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the builds-mathlib CI has verified that Mathlib builds against this PR label Nov 16, 2023
@leanprover-community-mathlib4-bot
Copy link
Collaborator

Comment on lines +236 to +240
def validatePkgName (pkgName : String) : LogIO PUnit := do
if pkgName.isEmpty || pkgName.all (· == '.') || pkgName.any (· ∈ ['/', '\\']) then
error "illegal package name"
if pkgName.toLower ∈ ["init", "lean", "lake", "main"] then
error "reserved package name"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am tempted to say "some validation is better than none, but couldn't we restrict to [0-9A-Za-z-_]*?, but won't. :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

@semorrison My current reason for avoiding this is twofold. We might wish to permit non-English or Mathematical characters in package names for broader appeal. Second, this validation currently only applies to the init/new not to the package declaration itself, so any rules here can currently be circumvented. In the future, though, have a more restricted subset for package names in general would likely be a good idea.

@tydeu tydeu merged commit 5d1d493 into leanprover:master Nov 16, 2023
17 checks passed
@tydeu tydeu deleted the lake/init-pkg-names branch December 21, 2024 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builds-mathlib CI has verified that Mathlib builds against this PR toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

validate project names
3 participants