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

Functions to inform user of correct access. #5

Merged
merged 5 commits into from
Oct 7, 2024
Merged

Functions to inform user of correct access. #5

merged 5 commits into from
Oct 7, 2024

Conversation

Nic-Chr
Copy link
Contributor

@Nic-Chr Nic-Chr commented Jul 22, 2024

Initial functions that check and inform the user of their access to the lookups directory.

The way I've set it up is to check access once the package is loaded (either through library or by accessing any function) and if they have access a message appears telling them that this is the case. This message will appear once per session so basically once the package is loaded.
If at the point of loading the package they do not have access, a warning is thrown informing them of this and steps to remedy it.

This is done internally through the check_access() function which throw either an error or a warning, depending on what you prefer (specified through the error_on_no_access arg).

I've done it this way so that when loading the package it doesn't cause a user's entire script to fail just because they may or may not use the lookup files.
But if we want to internally use check_access(), say at the start of get_spd() then an error will be thrown by default if there is no access (unlikely as the access was checked at the point of loading the package).

I've exported a have_access() function which just returns TRUE or FALSE depending on if the user has access to the lookups dir.

R/access.R Show resolved Hide resolved
@Moohan Moohan requested review from Moohan, a team and bnowok and removed request for a team October 7, 2024 11:44
@Moohan Moohan linked an issue Oct 7, 2024 that may be closed by this pull request
Copy link
Member

@Moohan Moohan left a comment

Choose a reason for hiding this comment

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

Had another look and all seems good to me.

@Moohan Moohan merged commit 275d4f4 into main Oct 7, 2024
3 of 5 checks passed
@Moohan Moohan deleted the check_access branch October 7, 2024 13:18
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

Successfully merging this pull request may close these issues.

Helpful message if user doesn't have access to folders
2 participants