Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kseo/envsubst
Docker style environment variables substitution for Dart
https://github.com/kseo/envsubst
Last synced: 26 days ago
JSON representation
Docker style environment variables substitution for Dart
- Host: GitHub
- URL: https://github.com/kseo/envsubst
- Owner: kseo
- License: bsd-3-clause
- Created: 2016-09-30T05:47:45.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-05T15:48:45.000Z (about 8 years ago)
- Last Synced: 2023-08-20T21:53:13.454Z (about 1 year ago)
- Language: Dart
- Homepage: https://pub.dartlang.org/packages/envsubst
- Size: 12.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# envsubst
[![Build Status](https://travis-ci.org/kseo/envsubst.svg?branch=master)](https://travis-ci.org/kseo/envsubst)
Docker style environment variables substitution for Dart.
Environment variables are notated either with $variable_name or
${variable_name}. They are treated equivalently and the brace syntax is
typically used to address issues with variable names with no whitespace,
like ${foo}_bar.The ${variable_name} syntax also supports a few of the standard bash
modifiers as specified below:* ${variable:-word} indicates that if variable is set then the result will
be that value. If variable is not set then word will be the result.
* ${variable:+word} indicates that if variable is set then word will be the
result, otherwise the result is the empty string.In all cases, word can be any string, including additional environment
variables.Escaping is possible by adding a \ before the variable: \$foo or \${foo},
for example, will translate to $foo and ${foo} literals respectively.# Examples
## Using `envsubst` programatically
```dart
import 'package:envsubst/envsubst.dart';main() {
String input = r'Hello $HOME';
String output = envSubst(input);
print(output); // print 'Hello /Users/kseo'
}
```## Using via cli
```
$ envsubst.dart < input.txt > output.txt
$ echo 'welcome $HOME' | envsubst
```# Other Projects
If you are a Go programmer, see [a8m/envsubst][a8m/envsubst].
[a8m/envsubst]: https://github.com/a8m/envsubst