Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add support for a simple config file#125

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

molawson
Copy link
Contributor

Following on from conversation in#124, I'm taking a pass at what I think is a useful but fairly simple approach to supporting a config file. I'd love to hear any and all feedback on this. I see this as a viable solution in particular but also as a means to have more concrete discussions about the topic generally.

Context

As syntax_tree gains wider usage, it'll be very helpful to allow projects to commit their particular configs within their repo for use by any tool that usesstree instead of having to create wrapper scripts, rely on rake tasks that come with their own overhead, or manually keep settings up to date among all contributors.

Approach

This set of changes takes inspiration fromSorbet to provide users with a simple config file that's also easy to parse and use within the gem. It's a text file that has the exact options you'd pass on the command line, each on their own line. These are parsed and prepended to the arguments array withinCLI.run, still allowing for other options to passed from the command line.

Limiting Scope (and Future Extensions)

I decided to restrict this only to the command line options and avoid the source files argument, opting to let other tools pass their own source file from the command line, which is preferable for tools like editor integrations that might interact with a single file at a time. If users want to interact with all of their Ruby files at once, the rake tasks are perfect for providing larger, static patterns of files. And since they useCLI.run as well, they'll pick up options from a.syntax_tree file, if present.

I also opted for only supporting a single .syntax_tree file at the project root. If there's a need for multiple configs or config locations, this can be easily extended to look up through a directory structure or accept an option for a specific config file location (or even a different filename). Those felt out of scope for this initial support.

@kddnewton
Copy link
Member

Looking at the code, I'm actually more amenable to this than I was. It's pretty clean, and I'm less worried about maintaining it than I was.

A couple of small tweaks and I'll merge this:

  • Can you change the name of the file to.streerc? I'm hesitant to use.syntax_tree because that makes me think it might be used at runtime even if the CLI isn't used. Naming it after the executable makes me think it's for configuring the CLI.
  • Can you put the name of the file into a constant and then reference that constant in the tests? That'll make it a little more maintainable if we change it in the future.

@molawson
Copy link
ContributorAuthor

Thanks for taking a look so quickly! I'm happy to make both of those changes.

As syntax_tree gains wider usage, it'll be very helpful to allowprojects to commit their particular configs within their repo for use byany tool that uses `stree` instead of having to create wrapper scripts,rely on rake tasks that come with their own overhead, or manually keepsettings up to date among all contributors.This set of changes takes inspiration from sorbet to provide users witha simple config file that's also easy to parse and use within the gem.It's a text file that has the exact options you'd pass on the commandline, each on their own line. These are parsed and prepended to thearguments array within `CLI.run`, still allowing for other options topassed from the command line.I decided to restrict this only to the command line options and avoidthe source files argument, opting to let other tools pass their ownsource file from the command line, which is preferable for tools likeeditor integrations that might interact with a single file at a time. Ifusers want to interact with all of their Ruby files at once, the raketasks are perfect for providing larger, static patterns of files. Andsince they use `CLI.run` as well, they'll pick up options from a.streerc file, if present.I also opted for only supporting a single .streerc file at the projectroot. If there's a need for multiple configs or config locations, thiscan be easily extended to look up through a directory structure oraccept an option for a specific config file location (or even adifferent filename). Those felt out of scope for this initial support.
@kddnewtonkddnewton merged commit3b81273 intoruby-syntax-tree:mainAug 1, 2022
@kddnewton
Copy link
Member

Thanks!

edgartheunready reacted with hooray emojiedgartheunready and molawson reacted with heart emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@molawson@kddnewton

[8]ページ先頭

©2009-2025 Movatter.jp