Replace sudo
param with maybe_sudo
method.
#22
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
maybe_sudo
method creates a new command based on whethersudo
might be needed and, if so, whetherpkglibdir
is writable. Ifsudo
is true andpkglibdir
is not writable it creates a Command withsudo
as the program and the program passed as its first argument. Otherwise it returns a Command with the passed program.With that intelligence, remove the
sudo
param from the interface and all methods. There will be no need to specifysudo
as a boolean, as the package can figure it out for itself.In the future it might be necessary to allow the user to specify a path to
sudo
(andmake
andcargo
and whatever else?), but for now it will be enough to have the user make sure that such commands are in the path.Also remove
mut
fromPgConfig::get
, as it's unnecessary and makes its usage more difficult. Found while using it inmaybe_sudo
.