-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎌 flags: Take -a and -p from environment as default (#5)
Take the values for the flags `-a` and `-p` from environment variables as the default, still allowing them to be overridden on the command line. Sometimes using `servedir`, you may always want to listen on all interfaces but the default invocation of `servedir` in a Makefile recipe does not specify `-a`. You can now set `SERVEDIR_ALL_INTERFACES=true` in the environment and these pre-canned `servedir` invocations can work with your defaults. This switches the use of the `flag` package to use an explicit `FlagSet` instead of using the global one in the `flag` package. Using the global one makes it a lot harder to test as flags get redefined. This merges the following commits: * Remove globals when parsing flags * Take -a and -p from environment as default Makefile | 2 +- main.go | 51 +++++++++++++++++++++++++++++++++------------------ main_test.go | 16 ++++++++++++++-- 3 files changed, 48 insertions(+), 21 deletions(-) Pull-Request: #5
- Loading branch information
Showing
3 changed files
with
48 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters