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,
)
| 10 | |
| 11 | |
| 12 | def 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', |
nothing calls this directly
no outgoing calls
no test coverage detected