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

Allow consulate kv get to return recursive listing of keys? #56

Closed
MWers opened this issue Jul 10, 2015 · 5 comments
Closed

Allow consulate kv get to return recursive listing of keys? #56

MWers opened this issue Jul 10, 2015 · 5 comments

Comments

@MWers
Copy link
Contributor

MWers commented Jul 10, 2015

What do you think about adding a -r option to consulate kv get to request all keys in a given path? Like this:

$ consulate kv get test/recursive/one
1

$ consulate kv get test/recursive/two
2

$ consulate kv get test/recursive/three
3

$ consulate kv get test/recursive
None

$ consulate kv get -r test/recursive
test/recursive/one   1
test/recursive/two   2
test/recursive/three 3

I'd be happy to add it to the CLI and submit a pull request, just wanted to make sure that it's a welcome contribution.

@gmr
Copy link
Owner

gmr commented Jul 10, 2015

Sounds great :)

@MWers
Copy link
Contributor Author

MWers commented Jul 10, 2015

Cool!

Quick question... This is what I've implemented:

$ consulate kv get -r test/recursive/
test/recursive/KEY_1    one
test/recursive/KEY_2    two
test/recursive/KEY_3    three

It would be nice to offer an option similar to envconsul where the prefix is trimmed from the resulting keys, like this:

$ consulate kv get -r test/recursive/
KEY_1   one
KEY_2   two
KEY_3   three

Or with a shorter prefix, like this:

$ consulate kv get -r test/
recursive/KEY_1 one
recursive/KEY_2 two
recursive/KEY_3 three

Do you think that this should be the default? Or should we offer a flag, like -t, --trim, to trim the prefix from the output?

Thanks!

@gmr
Copy link
Owner

gmr commented Jul 10, 2015

I do not think it should be the default, and --trim # would be good where # defaults to 1.

@MWers
Copy link
Contributor Author

MWers commented Jul 10, 2015

What would the number in --trim # do? Trim one level of prefix? I was thinking that --trim wouldn't take a number but it would signify that we should subtract the full prefix given to the cli from the key returned, like this:

# full keys:
# test/recursive/KEY_1
# test/recursive/KEY_2
# test/recursive/KEY_3

# default output:
$ consulate kv get -r test/recursive/
test/recursive/KEY_1    one
test/recursive/KEY_2    two
test/recursive/KEY_3    three

# trimmed output:
$ consulate kv get -r --trim test/recursive/
KEY_1   one
KEY_2   two
KEY_3   three

# trimmed output (shorter prefix specified as arg):
$ consulate kv get -r --trim test/
recursive/KEY_1   one
recursive/KEY_2   two
recursive/KEY_3   three

Would this work?

Thanks!

@gmr
Copy link
Owner

gmr commented Jul 11, 2015

Sure.. was just thinking that adding a default # of 1 that could be overridden would allow for

$ consulate kv get -r test
test/recursive/KEY_1    one
test/recursive/KEY_2    two
test/recursive/KEY_3    three

$ consulate kv get -r --trim test
recursive/KEY_1   one
recursive/KEY_2   two
recursive/KEY_3   three

$ consulate kv get -r --trim 2 test
KEY_1   one
KEY_2   two
KEY_3   three

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