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

feat: prefer os specific config dirs#616

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

Open
tjblackheart wants to merge5 commits intosymfony-cli:main
base:main
Choose a base branch
Loading
fromtjblackheart:feat/config-userhome

Conversation

@tjblackheart
Copy link

Closes#133

@tjblackhearttjblackheart changed the titleprefer os specific config dirsfeat: prefer os specific config dirsMay 16, 2025
Copy link
Member

@tucksauntucksaun left a comment

Choose a reason for hiding this comment

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

Thank you for starting the work on this


home,err:=os.UserHomeDir()
iferr!=nil {
home="."
Copy link
Member

Choose a reason for hiding this comment

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

Given my last comment it would be "covered"/"used" as the latest fallback so I would not use it here (inverting the condition and use the legacy only if present)

Copy link
Author

Choose a reason for hiding this comment

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

I don't understand. "home" here is just a fallback in case anything goes wrong with the detection?

Copy link
Author

Choose a reason for hiding this comment

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

... a more proper way would be to use os.Getwd() I guess

Copy link
Member

@tucksauntucksaunMay 20, 2025
edited
Loading

Choose a reason for hiding this comment

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

my point is that we have to handle a global fallback case if everything fails.
this is the. case.
because we will handle it as a last resort anyway, we don't have to deal with it here, which allows for early returns without variables leaking or inaccurate naming (the naming is inaccurate in the lastreturn legacy in the sense it is a fallback not necessarily a legacy path). eg, something as:

// use the old path if it exists alreadyifhome,err:=os.UserHomeDir();err==nil {legacyPath:=filepath.Join(home,"."+confDir)if_,err:=os.Stat(legacyPath);!os.IsNotExist(err) {returnlegacyPath}}

Copy link
Author

@tjblackhearttjblackheartMay 20, 2025
edited
Loading

Choose a reason for hiding this comment

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

I see, thanks for the explanation. "home" at this point was the base for the following legacy folder check and also the check for a macos~/.config. I guess if we remove the macos stuff this can go too.

If we include this like your proposal though, legacyPath will be needed again in the last return.

Copy link
Author

Choose a reason for hiding this comment

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

Hey@tucksaun, you think we can finish up this little thing? If these mere 10 lines of code are somehow not up to your standard please say so and I just close it, no problem. If not, I don't see whats the hold up. Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

If we include this like your proposal though, legacyPath will be needed again in the last return.

No because the last return (acting as a fallback) would then bereturn "./." + confDir.

Overall this organisation is mostly nice for us maintainers because it means theif block handling the legacy path is only responsible for handling legacy, not the fallback:

  • we can have a warning about the use of the legacy path and the need to migrate
  • we only have to remove this block when we remove support for legacy config directories

Copy link
Author

Choose a reason for hiding this comment

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

No because the last return (acting as a fallback) would then be return "./." + confDir.

Which is exactly whatlegacyPath is set to beforehand in any case. But sure, i've changed it to a hardcoded path.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@tucksauntucksauntucksaun left review comments

+1 more reviewer

@shyimshyimshyim approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Use system config folder to store files

3 participants

@tjblackheart@tucksaun@shyim

[8]ページ先頭

©2009-2025 Movatter.jp