MCPcopy Index your code
hub / github.com/theskumar/python-dotenv / run

Function run

src/dotenv/cli.py:184–201  ·  view source on GitHub ↗

Run command with environment variables present.

(ctx: click.Context, override: bool, commandline: tuple[str, ...])

Source from the content-addressed store, hash-verified

182)
183@click.argument("commandline", nargs=-1, type=click.UNPROCESSED)
184def run(ctx: click.Context, override: bool, commandline: tuple[str, ...]) -> None:
185 """Run command with environment variables present."""
186 file = ctx.obj["FILE"]
187 if not os.path.isfile(file):
188 raise click.BadParameter(
189 f"Invalid value for '-f' \"{file}\" does not exist.", ctx=ctx
190 )
191 dotenv_as_dict = {
192 k: v
193 for (k, v) in dotenv_values(file).items()
194 if v is not None and (override or k not in os.environ)
195 }
196
197 if not commandline:
198 click.echo("No command given.")
199 sys.exit(1)
200
201 run_command([*commandline, *ctx.args], dotenv_as_dict)
202
203
204def run_command(command: List[str], env: Dict[str, str]) -> None:

Callers

nothing calls this directly

Calls 2

dotenv_valuesFunction · 0.85
run_commandFunction · 0.85

Tested by

no test coverage detected