From e1fa109a3195a9fedcb635841ca1907b764ada1f Mon Sep 17 00:00:00 2001 From: Jesse Szwedko Date: Thu, 10 Aug 2017 17:54:24 -0700 Subject: [PATCH] Define flag source precedence in README Fixes #646 --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 2bbbd8e..883cc10 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ applications in an expressive way. + [Ordering](#ordering) + [Values from the Environment](#values-from-the-environment) + [Values from alternate input sources (YAML, TOML, and others)](#values-from-alternate-input-sources-yaml-toml-and-others) + + [Precedence](#precedence) * [Subcommands](#subcommands) * [Subcommands categories](#subcommands-categories) * [Exit code](#exit-code) @@ -656,6 +657,15 @@ func main() { } ``` +#### Precedence + +The precedence for flag value sources is as follows (highest to lowest): + +0. Command line flag value from user +0. Environment variable (if specified) +0. Configuration file (if specified) +0. Default defined on the flag + ### Subcommands Subcommands can be defined for a more git-like command line app.