Skip to main content

Generate sh and ps1 scripts from .env files to apply for the process

Project description

dot_to_osscript

The most universal way to work with .env files!

Generate script based on .env and files, so it could be imported to the current process

Install

pip install dot-to-osscript

Usage

Usage: python -m dot_to_osscript [OPTIONS]

Options:

`-p`, `--powershell`     Generate .env.ps1
`-s`, `--shell`          Generate .env.sh
`-e`, `--env-file TEXT`  Input file  [default: ./.env]
`-a`, `--path-append`    Appent to existing Path variable

Example

We have some directory (./) with .env file:

MSYSTEM=mingw32
TEST_var="TEST VAL"
PATH=/my_app/bin

We execute: python -m dot_to_osscript -psa and get :

.env.ps1

Set-Variable -Name 'MSYSTEM' -Value 'mingw32'
Set-Variable -Name 'TEST_var' -Value '"TEST VAL"'
Set-Variable -Name 'Path' -Value '$env:Path;/my_app/bin'

.env.sh

MSYSTEM='mingw32'
TEST_var='"TEST VAL"'
PATH='$PATH:/my_app/bin'

We could import files to the current command line process:

For PowerShell: . .env.ps1

For bash: source .env.sh

Tip

The best idea is to use oneliners.

Powershell:

python -m dot_to_osscript -pa; . .env.ps1; Remove-Item .env.ps1

bash:

python -m dot_to_osscript -pa; source .env.sh; rm ./.env.sh

It generate ps1/sh file, import it and remove the file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dot_to_osscript-0.3.1.tar.gz (2.9 kB view hashes)

Uploaded Source

Built Distribution

dot_to_osscript-0.3.1-py3-none-any.whl (4.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page