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

Suggestion: Add configuration init with data instead of url #810

Open
doozMen opened this issue Sep 20, 2024 · 3 comments
Open

Suggestion: Add configuration init with data instead of url #810

doozMen opened this issue Sep 20, 2024 · 3 comments

Comments

@doozMen
Copy link

doozMen commented Sep 20, 2024

Hei I'm using, and loving, the formatting tool inside my code generator. I embed the config json file into the code as it is a cli tool that runs on linux. This means in my package manifest i use resources: [.embedInCode(swift_format.json)] which would not produce a url but data.

As the let config = try Configuration(contentsOf: url) only accepts an url would it be ok to make a PR and add an init that accepts data?

My current workaround is to create a temporary file but that seams like inefficient.

  let tempFile = try Folder.temporary
    .createFile(
      named: "swift_format.json",
      contents: Data(PackageResources.swift_format_json))
@ahoppen
Copy link
Member

ahoppen commented Sep 20, 2024

Synced to Apple’s issue tracker as rdar://136347689

@andre-richter
Copy link

This could also serve as an enabler for the command-line tool for getting a future extension to pass the config as a string inline, like clang-format's --style="{key: value, ...}" 👍

@allevato
Copy link
Member

Which version of the swift-format package are you using? This was added in #634, so it should be available in the 6.0 release.

This could also serve as an enabler for the command-line tool for getting a future extension to pass the config as a string inline, like clang-format's --style="{key: value, ...}" 👍

The PR above also added this. We should probably update the README to reflect that, instead of just the argument help text.

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

No branches or pull requests

4 participants