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

Please add support to escape a $ dollar sign in a config file #27

Open
MoacirSchmidt opened this issue May 7, 2019 · 1 comment
Open

Comments

@MoacirSchmidt
Copy link

MoacirSchmidt commented May 7, 2019

I have a config file like that:

file "config.yaml":

password: $ya123m

when it is read from code below:

import 'dart:io';
import 'package:safe_config/safe_config.dart';

class AppConfig extends Configuration {
 	AppConfig(String fileName) : super.fromFile(File(fileName));
	
	String password;
}

void main() {
  var config = new AppConfig("config.yaml");
  print("${config.password}"); // -> null????
}

I receive the unhandled exception:
"Invalid configuration data for 'AppConfig'. Missing required values: 'password'"

If I remove $ from 'password' field this error goes away

It seems that there is no support to escape '$' sign in config files (although yaml package seems to support that). Could you please add that. I think there is already a standard where double '$' ($$) is used to escape $ sign.

I have already tried $$ and \$

Thank you very much

@joeconwaystk
Copy link
Member

A leading (and only a leading) $ redirects the value to an environment variable. Adding a $$ escape sounds reasonable.

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