Commit graph

52 commits

Author SHA1 Message Date
Tyler Butters
9e7b3a1bb5 Improve common mistake when using Cobra flagsets
Users get tripped up when accidentally mix & matching
Cobra's `Flags()` and `PersistentFlags()`, where they will
call `Lookup(<flag>)` on the wrong flagset.

Following the README, users would call `Lookup` to fill in
the flag source parameter of Viper's `BindPFlag`, but by
using the wrong flagset, the parameter would simply be nil.
This would then result in a runtime panic whenever trying
to retrieve the flag's value with `Get(<flag>)`.

This work alleviates the mistake by:
+ Performing a nil check in `BindPFlag` and causing
  `BindFlagValue` to return an error if the parameter
  flag is nil, as it would be during the expected mixup.
+ Updating the godoc of `BindPFlag` and the README's example,
  to drill the fact that `Flags` and `PersistentFlags` are
  different flagsets.
+ Adding a test for this pattern of binding nil on accident
  and then retrieving flags. Before these changes, this test
  would panic. Now, the test instead gracefully errors and
  applies no changes to the viper instance.
2017-10-08 13:24:04 -04:00
JG²
25b30aa063 Add Clairctl as a Go project that uses Viper
See #354
2017-07-22 23:52:07 -06:00
Brad Peabody
04691bc570 Improve documentation for flags
See #329
2017-07-22 23:26:21 -06:00
Albert Nigmatzianov
16a9458573 Fix indentation in README.md
See #345
2017-07-22 22:54:24 -06:00
Anthony Fok
df7314a14e Make minor copy-editing changes to README.md 2017-07-21 04:20:10 -06:00
Nick Miyake
a1ecfa6a20 Fix apostrophes in README
Fix "it's" -> "its".
2017-06-10 01:09:38 +02:00
Nils Landt
c14ce6d43c Correct FlagValue interface examples in Readme (#254)
`IsChanged` is actually named `HasChanged`, and the examples were missing function return declarations, so you couldn't just copy/paste it.
2016-10-12 11:40:13 +02:00
Albert
21ea37b673 Fix space between Go projects and badges 2016-10-09 21:34:00 +02:00
Albert
b61deff907 Add GoDoc badge 2016-10-09 20:33:40 +02:00
Benoît Masson
ec4eb2fa85 Nested maps (#195)
Fixes #71, #93, #158, #168, #209, #141, #160, #162, #190

* Fixed: indentation in comment
* Fixed: Get() returns nil when nested element not found
* Fixed: insensitiviseMaps() made recursive so that nested keys are lowercased
* Fixed: order of expected<=>actual in assert.Equal() statements
* Fixed: find() looks into "overrides" first
* Fixed: TestBindPFlags() to use a new Viper instance
* Fixed: removed extra aliases from display in Debug()
* Added: test for checking precedence of dot-containing keys.
* Fixed: Set() and SetDefault() insert nested values
* Added: tests for overriding nested values
* Changed: AllKeys() includes all keys / AllSettings() includes overridden nested values
* Added: test for shadowed nested key
* Fixed: properties parsing generates nested maps
* Fixed: Get() and IsSet() work correctly on nested values
* Changed: modifier README.md to reflect changes
2016-10-08 10:00:18 +02:00
Albert
16990631d4 Fix typo in README (#227)
Fixed typo & superfluous white space in README
2016-08-30 16:32:46 +02:00
Bryan Liles
6d2589cd85 Update Readme with doit's new location
doit has been moved and renamed to doctl
2016-08-05 09:15:51 +02:00
Steve Francia
dd66c894de Populate readme with viper based apps 2016-02-08 17:01:43 -05:00
ryanwalls
30ce444d04 Update README with info about supporting Java properties files 2016-01-30 11:44:53 -07:00
David Calavera
c8c6312ace Add information about flag interfaces to the readme file.
Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-12-24 10:16:42 -05:00
Lei Feng
105e3d0d19 Add Sub() for Viper, which returns a branch of a Viper instance. 2015-12-24 22:44:14 +08:00
patdhlk
79971f1ae7 add HCL support to the README file 2015-12-15 14:44:21 -05:00
Sanjay Bhandari
5c53af5e4f README: describe interworking with flag package 2015-12-15 12:58:30 -05:00
Abhinandan
823bc1371b Document the use of struct tags to map the dissimilar fields. 2015-12-15 12:57:56 -05:00
Steve Francia
90b31f671f Merge pull request #138 from derekparker/fix-typo
readme: Fix typo
2015-12-11 21:21:22 -05:00
Jonathan Boulle
ce08532bfd Correct "etcd" naming
The project should always be referred to in lowercase.
2015-12-11 16:14:08 -05:00
Derek Parker
cc3dd557e0 readme: Fix typo 2015-12-03 11:47:09 -08:00
spf13
e37b56e207 Add dynamic reading of config file support 2015-11-09 23:22:04 -05:00
Vlad Didenko
a7ef020a9a Clarify CWD search. Fixes #32 2015-11-06 14:50:12 -05:00
James Mintram
3041a43deb Noticed a couple ot typos 2015-11-04 18:06:12 -05:00
David Symonds
493be7d534 Fix import syntax in README.md. 2015-11-04 18:05:20 -05:00
Steve Francia
d2f75b4bef Add logo to readme 2015-11-02 11:07:43 -05:00
Matt Surabian
1967d93db7 Fixed #36: Changed Marshal to Unmarshal throughout. 2015-09-08 08:24:57 -04:00
jackspirou
2abb1bebfd Readme fixes and small edits 2015-07-30 10:46:19 -07:00
Maxime Horcholle
1e6a237e05 Syntax highlighting 2015-07-30 10:28:50 -07:00
bep
be5ff3e484 Make the remote features optional 2015-05-30 21:28:45 +02:00
oliveagle
0d75ecea1c update README.md
[close #66]
2015-05-19 10:07:30 -04:00
oliveagle
2a7f7f40fc add README.md, and fix strings.ToLower(configType) 2015-05-19 10:07:21 -04:00
Kiril Zvezdarov
2e47d9ed4a Added doc entry on nested key access 2015-05-02 14:20:33 -04:00
The Gitter Badger
2763b90eff Added Gitter badge 2015-05-01 20:02:50 +00:00
Kiril Zvezdarov
39ab3ca72e Noted that ReadInConfig returns errors that can be handled 2015-04-02 17:07:32 -04:00
Eran Chetz
ac722f39d3 Change small syntax error in Env Example 2015-03-26 15:24:28 +02:00
Anthony Fok
0c5f3e2462 Minor revisions to README.md
* Change the order to "JSON, TOML and YAML" because that is
   the order that Viper attempts to find the config file,
   as listed in SupportedExts string array

 * Rename "Indexes" to "Taxonomies" (re: Hugo)

 * GitHub now forces https, so update GitHub URLs accordingly

 * Add links to Wikipedia pages about Viper and Cobra Commander
   in case the users do not know the G.I. Joe reference

 * Other minor copyediting
2015-03-07 03:52:13 -07:00
Chance Zibolski
1258332127 Fix whitespace 2015-03-06 11:21:50 -08:00
Chance Zibolski
03fb74b5d7 Support rewriting env keys 2015-03-06 11:21:17 -08:00
Chance Zibolski
ededa04e0b Add viper.GetDuration 2015-03-06 10:11:47 -08:00
spf13
d8f2aa78d4 More intelligent AutomaticEnv behavior and updated documentation. 2014-12-22 22:55:07 -05:00
spf13
54fed16054 Adding docs for SetEnvPrefix and cleaning up docs. 2014-12-22 21:45:56 -05:00
spf13
1022d75c73 Adding Support for Environment variable prefixes 2014-12-22 18:31:11 -05:00
spf13
cacbc4c733 Rewriting the documentation 2014-12-07 02:03:49 +01:00
Andrew Cohen
90193e564a Add travis ci support 2014-11-13 16:36:34 -05:00
Michael Grosser
bddcf7e104 Fix typo 2014-10-29 07:43:14 +01:00
Brian Ketelsen
e55c96ecc9 document consul support, not requirement to set config type for remote KV stores 2014-10-27 21:53:22 -04:00
Brian Ketelsen
51da30f655 Added basic documentation, pointers to crypt repository, and tests for precedence 2014-10-27 15:32:46 -04:00
spf13
8b744a9310 Added "ConfigFileUsed" function 2014-04-07 23:35:40 -04:00