Skip to content

Auto load .env file in current directory#249

Merged
darrenburns merged 6 commits into
darrenburns:mainfrom
kkHAIKE:flags
Apr 13, 2025
Merged

Auto load .env file in current directory#249
darrenburns merged 6 commits into
darrenburns:mainfrom
kkHAIKE:flags

Conversation

@kkHAIKE

@kkHAIKE kkHAIKE commented Apr 10, 2025

Copy link
Copy Markdown
Contributor

And add short flag "-c" alias to "--collection"

@kkHAIKE kkHAIKE changed the title Auto laod .env file in current directory Auto load .env file in current directory Apr 11, 2025
@kkHAIKE

kkHAIKE commented Apr 13, 2025

Copy link
Copy Markdown
Contributor Author

I don't think it's necessary to add the --no-auto-env parameter.
The .env file is automatically loaded in many scenarios or tools. Even if a .env file not specifically written for the posting tool is loaded, the posting tool won't be affected (since it doesn't reference any variables from it).

The current best practice for using the posting tool is to prepare a directory with the following structure:

. 
|- collection_name 
\- .env

Normally, we cd into this directory and execute --collection name --env .env, which feels a bit redundant.
So in this commit, I've changed it to just require -c name.

If customizability is really desired, we could add config.yaml configuration options to achieve this.
or simply autoload posting.env instead of .env.

PS: Also, I wonder if having a global configuration for collections would be better? (Since the current posting approach suggests that collections shouldn't contain metadata).
I'm currently facing an issue where I need to repeatedly configure the same auth and script settings across all paths.

@darrenburns

darrenburns commented Apr 13, 2025

Copy link
Copy Markdown
Owner

I think you're right regarding the no-auto-env param, I didn't think it through. I'll remove that.

edit: moved chat about global config to a discussion: #146 (comment)

@kkHAIKE

kkHAIKE commented Apr 13, 2025

Copy link
Copy Markdown
Contributor Author

Would it be better to autoload posting.env instead? This would avoid conflicts with other tools sharing the same .env file, while also being more explicit (not a hidden file) and clearly indicating its intended use.

@darrenburns

Copy link
Copy Markdown
Owner

Hmm - yes, that's a good point. I think it's better to be explicit about that since .env files inside are likely unrelated to Posting.

@darrenburns darrenburns merged commit 4f1b565 into darrenburns:main Apr 13, 2025
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

Successfully merging this pull request may close these issues.

2 participants