Parse a dufrc file to allow for default settings #292
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.
I found myself wanting for a default
-only local
, so I hacked together a good olddufrc
support – default commandline options can be stored in there as so:and unless a
-norc
option is passed in, these options will get included when runningduf
.flag.Parse() doesn't allow for passing in a string, so we modify os.Args based on the contents of XDG_CONFIG_HOME/dufrc.
I'm not sure how flag.Parse() would react to being called multiple times, and how that'd affect default options – and didn't want to rely on testing it, since if it's not in the docs then it might as well change in the future – so
-norc
is added to options to not confuseflag
, but it's checked for manually to avoid double-Parse()
.Each arg is on the separate line – I'm not sure if Go has anything for parsing shell quotes, I didn't want to deal with that and/or introduce an additional dependency.
TODO:
duf
support any?)