Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Setting up a Config file #5

Open
JoaquimEsteves opened this issue Dec 10, 2020 · 1 comment
Open

Request: Setting up a Config file #5

JoaquimEsteves opened this issue Dec 10, 2020 · 1 comment

Comments

@JoaquimEsteves
Copy link

JoaquimEsteves commented Dec 10, 2020

Hello, I've been playing around with your package and I've loved I'm loving it so far!

I would, however, like to have an option in the cli to include a config file that would be expand the code's namespace.

Example:

# Config file ensures my path file exists and I can easily do something with it
# My aliases are also conveniently saved
pathlib import Path
P = print
if not (some_file := Path('./some_file')).exists():
    raise Exception("some_file doesn't exist!")
$ pwk '[P(line) for line in some_file.open().readlines())]' --config ./path/to/pwk_cfg.py

I'm currently working on this feature on my own fork; and would like to know if you'd be interested in a PR.

Why not edit pwk directly

This would allow me to have multiple config files for different projects, making it more convenient than hopping over to /usr/bin/pwk and editing the file directly or copy-pasting it everywhere.

What about name conflicts, won't this make it trickier to develop pwk itself?

We can pass the environment over to exec directly like so:

exec(python_cmd, {**globals, **vars_from_config})
@umlet
Copy link
Owner

umlet commented Jan 13, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants