MCPcopy Create free account
hub / github.com/theskumar/python-dotenv / get_cli_string

Function get_cli_string

src/dotenv/__init__.py:12–39  ·  view source on GitHub ↗

Returns a string suitable for running as a shell script. Useful for converting a arguments passed to a fabric task to be passed to a `local` or `run` command.

(
    path: Optional[str] = None,
    action: Optional[str] = None,
    key: Optional[str] = None,
    value: Optional[str] = None,
    quote: Optional[str] = None,
)

Source from the content-addressed store, hash-verified

10
11
12def get_cli_string(
13 path: Optional[str] = None,
14 action: Optional[str] = None,
15 key: Optional[str] = None,
16 value: Optional[str] = None,
17 quote: Optional[str] = None,
18):
19 """Returns a string suitable for running as a shell script.
20
21 Useful for converting a arguments passed to a fabric task
22 to be passed to a `local` or `run` command.
23 """
24 command = ['dotenv']
25 if quote:
26 command.append(f'-q {quote}')
27 if path:
28 command.append(f'-f {path}')
29 if action:
30 command.append(action)
31 if key:
32 command.append(key)
33 if value:
34 if ' ' in value:
35 command.append(f'"{value}"')
36 else:
37 command.append(value)
38
39 return ' '.join(command).strip()
40
41
42__all__ = ['get_cli_string',

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected