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

Function list

src/dotenv/cli.py:73–89  ·  view source on GitHub ↗

Display all the stored key/value.

(ctx: click.Context, format: bool)

Source from the content-addressed store, hash-verified

71 help="The format in which to display the list. Default format is simple, "
72 "which displays name=value without quotes.")
73def 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()

Callers 2

test_parse_variablesFunction · 0.85
test_parse_streamFunction · 0.85

Calls 2

stream_fileFunction · 0.85
dotenv_valuesFunction · 0.85

Tested by 2

test_parse_variablesFunction · 0.68
test_parse_streamFunction · 0.68