Display all the stored key/value.
(ctx: click.Context, format: bool)
| 71 | help="The format in which to display the list. Default format is simple, " |
| 72 | "which displays name=value without quotes.") |
| 73 | def list(ctx: click.Context, format: bool) -> None: |
| 74 | """Display all the stored key/value.""" |
| 75 | file = ctx.obj['FILE'] |
| 76 | |
| 77 | with stream_file(file) as stream: |
| 78 | values = dotenv_values(stream=stream) |
| 79 | |
| 80 | if format == 'json': |
| 81 | click.echo(json.dumps(values, indent=2, sort_keys=True)) |
| 82 | else: |
| 83 | prefix = 'export ' if format == 'export' else '' |
| 84 | for k in sorted(values): |
| 85 | v = values[k] |
| 86 | if v is not None: |
| 87 | if format in ('export', 'shell'): |
| 88 | v = shlex.quote(v) |
| 89 | click.echo(f'{prefix}{k}={v}') |
| 90 | |
| 91 | |
| 92 | @cli.command() |