Class UserChoices::EnvironmentSource
In: lib/user-choices/sources.rb
Parent: AbstractSource

Describe the environment as a source of choices.

Methods

Public Instance methods

Some environment variables have names you don‘t like. For example, $HOME might be annoying because of the uppercase. Also, if most of your program‘s environment variables have some prefix (see with_prefix) but you also want to use $HOME, you need a way to do that. You can satisfy both desires with

     EnvironmentSource.new.with_prefix("my_").mapping(:home => "HOME")

Environment variables beginning with prefix (a string) are considered to be user choices relevant to this script. Everything after the prefix names a choice (that is, a symbol). Dashes are converted to underscores. Examples:

  • Environment variable prefix-my-choice with prefix "prefix-" is choice <tt>:my_choice.
  • Environment variable PREFIX_FOO with prefix "PREFIX_" is choice <tt>:FOO

If you want an array of strings, separate the values by commas: ENV_VAR=a,b,c There‘s currently no way to escape a comma and no cleverness about quotes or whitespace.

[Validate]