deprecatedOptionDirectSource returns the source by which a deprecated option was directly set, ignoring any propagated ValueSource from sibling options that share the same Value pointer.
(inv *serpent.Invocation, opt serpent.Option)
| 1796 | // option was directly set, ignoring any propagated ValueSource from |
| 1797 | // sibling options that share the same Value pointer. |
| 1798 | func deprecatedOptionDirectSource(inv *serpent.Invocation, opt serpent.Option) serpent.ValueSource { |
| 1799 | if opt.Flag != "" { |
| 1800 | fl := inv.ParsedFlags().Lookup(opt.Flag) |
| 1801 | if fl != nil && fl.Changed { |
| 1802 | return serpent.ValueSourceFlag |
| 1803 | } |
| 1804 | } |
| 1805 | |
| 1806 | if opt.Env != "" { |
| 1807 | _, exists := inv.Environ.Lookup(opt.Env) |
| 1808 | if exists { |
| 1809 | return serpent.ValueSourceEnv |
| 1810 | } |
| 1811 | } |
| 1812 | |
| 1813 | if opt.ValueSource == serpent.ValueSourceYAML { |
| 1814 | // There is no straightforward way to check whether a |
| 1815 | // specific YAML key was present in the config file, so |
| 1816 | // we conservatively assume the deprecated key was used. |
| 1817 | return serpent.ValueSourceYAML |
| 1818 | } |
| 1819 | |
| 1820 | return serpent.ValueSourceNone |
| 1821 | } |
| 1822 | |
| 1823 | // translateSource provides the name of the source of the option, depending on the |
| 1824 | // supplied target ValueSource. |
no outgoing calls
no test coverage detected