dotenv-for-MATLAB

버전 1.1.4 (171 KB) 작성자: George
Load environment variables from a .env file.
다운로드 수: 73
업데이트 날짜: 2022/3/16

dotenv for MATLAB

A MATLAB implementation of dotenv

Storing configuration in the environment is one of the tenets of a 12-factor app. dotenv for MATLAB® lets you store configuration data (passwords, API keys, server names, etc.) outside of your code. This lets you share your code without sharing your configuration data.

screenshot

mathworks

View dotenv-for-MATLAB on File Exchange

Installation

Put dotenv.m somewhere on your search path.

Usage Example

dotenv() will try and load a file named .env from the current working folder. Alternatively, you can specify the path with dotenv('path/to/file.env').

.env

# Obligatory XKCD https://xkcd.com/936/
password=correct-horse-battery-staple 

file.m

d = dotenv();
opts = weboptions('HeaderField', ["accept", "any"; "authorization", d.env.password])
url = "https://myurl.com"
response = webread(url, opts);

Common places you may need to do this are weboptions(), working with remote data like S3 buckets, the Database Toolbox, or ftp().

Rules

The parsing engine currently supports the following rules:

  • empty lines are skipped
  • lines beginning with # are treated as comments
  • empty values become empty strings (DB_HOST= becomes DBHOST: '')
  • whitespace is removed from both ends of unquoted values (DB_HOST=some server becomes DB_HOST:'some server')
  • quoted values are escaped (DB_PASS=" some password " becomes DB_PASS:' some password ')

Examples are in the config directory.

FAQ

Should I commit my .env file?

No. You should put *.env in your .gitignore file. MATLAB.gitignore plus *.env is a good start.

Development Setup

Clone the repository. You can run runtests('tests') from the project root to run the unit test suite.

Bugs?

I would love to hear if this breaks on any weird strings or doesn't work the way you expected.

인용 양식

George (2024). dotenv-for-MATLAB (https://github.com/mathworks/dotenv-for-MATLAB/releases/tag/v1.1.4), GitHub. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2021b
R2016b 이상 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Debugging and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

GitHub 디폴트 브랜치를 사용하는 버전은 다운로드할 수 없음

버전 게시됨 릴리스 정보
1.1.4

See release notes for this release on GitHub: https://github.com/mathworks/dotenv-for-MATLAB/releases/tag/v1.1.4

1.1.3

See release notes for this release on GitHub: https://github.com/mathworks/dotenv-for-MATLAB/releases/tag/v1.1.3

1.1.2

See release notes for this release on GitHub: https://github.com/mathworks/dotenv-for-MATLAB/releases/tag/v1.1.2

1.1.1.0

See release notes for this release on GitHub: https://github.com/mathworks/dotenv-for-MATLAB/releases/tag/v1.1.1

1.1.0

Added support for continuous integration through Azure Pipelines and CircleCI

1.0.2

Improved documentation

1.0.1

Updated icon file

1.0.0

이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.
이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.