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

Parse String[] args commandline parameter #55

Closed
muuki88 opened this issue Jan 31, 2013 · 4 comments
Closed

Parse String[] args commandline parameter #55

muuki88 opened this issue Jan 31, 2013 · 4 comments

Comments

@muuki88
Copy link

muuki88 commented Jan 31, 2013

A nice feature would be to parse commandline parameters. E.g.

-db.user=muki -db.password=secret
public static void main(String[] args) {
   Config c = ConfigFactory.parseArray(args).getConfig("db");
   c.getString("user");
   c.getString("password");
}

If there is any interest, I would try to provide an implementation.

@havocp
Copy link
Collaborator

havocp commented Jan 31, 2013

You can do "-Ddb.user=muki" right now (as args to the jvm) - would that meet the need? What is the extra advantage of doing it this way?

@muuki88
Copy link
Author

muuki88 commented Jan 31, 2013

We are currently using Args4J to parse our application arguments. We would have to port all our application arguments to system properties.

Besides that, system properties and application arguments are different things.

Parsing arrays also provide an easier syntax to create a config on the fly. E.g.

String[] params = new String[] {"db.user", "muki", "db.password", "secret"};
ConfigFactory.parseArray(params);

These aren't very strong reason or common issues, but would be nice to have.

@havocp
Copy link
Collaborator

havocp commented Sep 20, 2013

(going through bugs) I think a command line parser is too much of its own complicated problem to bundle with a config library; what I'd probably do to handle this is take some command line parser lib, and write some glue from it to the config lib. Which sounds useful, but I think it's out of scope for this particular jar.

@havocp havocp closed this as completed Sep 20, 2013
@muuki88
Copy link
Author

muuki88 commented Sep 20, 2013

Yeah, I think you are right. For that I created a small library Config4CLI to close this gap.

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