env-alias 0.5.2__tar.gz → 0.5.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: env-alias
3
- Version: 0.5.2
3
+ Version: 0.5.3
4
4
  Summary: Powerful helper utility to create shell alias commands to easily set collections of environment variables often with secret values from a variety of data-sources and data-formats.
5
5
  License: BSD-2-Clause
6
6
  Keywords: env-alias,shell,env,alias,bash
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "env-alias"
7
- version = "0.5.2"
7
+ version = "0.5.3"
8
8
  description = "Powerful helper utility to create shell alias commands to easily set collections of environment variables often with secret values from a variety of data-sources and data-formats."
9
9
  authors = ["Nicholas de Jong <contact@nicholasdejong.com>"]
10
10
  license = "BSD-2-Clause"
@@ -6,7 +6,7 @@ from os import getenv
6
6
  from sys import argv
7
7
 
8
8
  __title__ = "Env Alias"
9
- __version__ = "0.5.2"
9
+ __version__ = "0.5.3"
10
10
 
11
11
  LOGGER_LEVEL = "info"
12
12
  if "--debug" in argv or getenv("ENVALIAS_DEBUG", "").lower().startswith(("true", "yes", "enable", "on")):
@@ -50,6 +50,10 @@ class EnvAliasDefinitions:
50
50
  if not definition_item.get("name"):
51
51
  definition_item["name"] = definition_key
52
52
 
53
+ if definition_item["name"] in ("none", "None"):
54
+ _name = definition_item.get("name")
55
+ logger.warning(f"Definition name is '{_name}' did you mean 'null' instead?")
56
+
53
57
  try:
54
58
  definitions.append(EnvAliasDefinition(**definition_item))
55
59
  except TypeError as e:
@@ -41,6 +41,14 @@ class EnvAliasGenerator:
41
41
  self.values_generated[definition.name] = value
42
42
  os.environ[definition.name] = str(value) # exists at this process and sub-process only
43
43
 
44
+ if definition.value_to:
45
+ if definition.value_to == "<stderr>":
46
+ print(value, file=sys.stderr)
47
+ elif definition.value_to == "<stdout>":
48
+ print(value, file=sys.stdout)
49
+ else:
50
+ raise EnvAliasException("Unsupported 'value_to' value encountered.")
51
+
44
52
  if definition._is_internal_only is True:
45
53
  logger.debug(
46
54
  f"Definition for {definition.name!r} defines a 'null' name for env-alias internal "
@@ -21,6 +21,7 @@ class EnvAliasDefinition:
21
21
 
22
22
  parser: Union[str, None] = None
23
23
  selector: Union[str, None] = _UNSET_SENTINEL
24
+ value_to: Union[str, None] = None
24
25
 
25
26
  keepass_password: Union[str, None] = None
26
27
  ansible_vault_password: Union[str, None] = None
@@ -39,6 +40,11 @@ class EnvAliasDefinition:
39
40
  if not self.source and not self.exec and not self.value and not self.ansible_vault_password_file:
40
41
  raise EnvAliasException(f"Must have one 'source', 'exec' or 'value' {_EXCEPTION_END}")
41
42
 
43
+ if isinstance(self.value_to, str):
44
+ self.value_to = self.value_to.lower()
45
+ if self.value_to not in ("<stderr>", "<stdout>"):
46
+ raise EnvAliasException(f"Invalid 'value_to' value, must be '<stderr>' or '<stdout>' {_EXCEPTION_END}")
47
+
42
48
  if self.keepass_password and self.ansible_vault_password:
43
49
  raise EnvAliasException(f"Cannot use both 'keepass_password' and 'ansible_vault_password' {_EXCEPTION_END}")
44
50
  if self.ansible_vault_password_file and (self.exec or self.source or self.value or self.keepass_password):
File without changes
File without changes