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

[SR-8257] Provide package init custom naming strategy #4770

Closed
masters3d opened this issue Jul 14, 2018 · 6 comments
Closed

[SR-8257] Provide package init custom naming strategy #4770

masters3d opened this issue Jul 14, 2018 · 6 comments

Comments

@masters3d
Copy link
Contributor

Previous ID SR-8257
Radar rdar://problem/42246107
Original Reporter @masters3d
Type New Feature
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels New Feature, StarterBug
Assignee JhonnyBillM (JIRA)
Priority Medium

md5: 8a8537b674120cb874c1adfdf50ef94c

Issue Description:

swift package init --help

OPTIONS:

--type empty|library|executable|system-module

Provide `package init ` option to allow custom name:

--packageName provide custom package name

Alternatively, we would provide a naming strategy based on the folder name. This is more involved an perhaps not needed if a custom name could be provided.

Provide `package init ` option to allow specifing the casing of the package name. Currently this is locked to `self.pkgname = dirname`. All my folder are snake case but all my package names are PascalCased.

--nameStrategy default|camelCase|PascalCase|snake_case

Since it seems to be convention to name packaes with Pascal case then we probably just need

--nameStrategy default|PascalCase

where default is the current verbarim of the name of the folder

1) We would guess if the source name is snake_case, camelCase or PascalCase

snake_case: no uppercase chars, _ or -

camelCase: first char lowercaase, some uppercase

PascalCase: first char uppercase some uppercase and lowercase letter.

2) If the name has any spaces, go back to default and print a message.

If we cant naively figure out on of the three cases above then just give up and go back to default.

Sample code:

https://github.com/apple/swift/blob/master/stdlib/public/SDK/Foundation/JSONEncoder.swift

```

fileprivate static func _convertFromSnakeCase( stringKey: String) -> String {...}

fileprivate static func _convertToSnakeCase( stringKey: String) -> String {...}

```

@ankitspd
Copy link
Member

Adding an option to specify the name using `--packageName` sounds good to me!

@ankitspd
Copy link
Member

@swift-ci create

@swift-ci
Copy link
Contributor

Comment by Jhonny Bill Mena (JIRA)

Seems interesting.

Can I work at this?

@masters3d
Copy link
Contributor Author

go for it. as far as the name of the option, I think --name would be sufficient. Have fun!

swift package init --name myNameHere

@ankitspd
Copy link
Member

Yep, --name sounds good.

@swift-ci
Copy link
Contributor

Comment by Jhonny Bill Mena (JIRA)

#1693

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants