<commit_before># jsonconsul

[![Build Status](https://travis-ci.org/vsco/jsonconsul.svg)](https://travis-ci.org/vsco/jsonconsul)

`jsonconsul` allows the creation of json files from the values that
are located in Consul. It also contains the ability to import KV keys
into Consul.

## Usage

### Import

A json config can be used to update key values in Consul.

Here is an example file named `example.json`
```
{"foo":{"bar":"test","blah":"Test","do":"TEST","loud":{"asd":{"bah":"test"}}}}
```

Now if we want to import this into the root prefix then we'd do the following:

```sh
jsonconsul import example.json
```

To import into an alternate prefix the following needs to be done:

```sh
jsonconsul import -prefix='vsco/buzz' example.json
```

### Export

There are five ways to run `jsonconsul export`. There are:

 - Output to STDOUT
 - Output to file
 - Output to file but timestamp the output file and symlink to name.
 - Poll and output to file after a duration.
 - Poll and output to file after a duration but with timestamped output file.

#### Output to STDOUT
```sh
jsonconsul export -prefix="foo"
```

#### Output to file
```sh
jsonconsul export -prefix="foo" foo.json<commit_msg>Updated README with include-prefix example<commit_after># jsonconsul

[![Build Status](https://travis-ci.org/vsco/jsonconsul.svg)](https://travis-ci.org/vsco/jsonconsul)

`jsonconsul` allows the creation of json files from the values that
are located in Consul. It also contains the ability to import KV keys
into Consul.

## Usage

### Import

A json config can be used to update key values in Consul.

Here is an example file named `example.json`
```
{"foo":{"bar":"test","blah":"Test","do":"TEST","loud":{"asd":{"bah":"test"}}}}
```

Now if we want to import this into the root prefix then we'd do the following:

```sh
jsonconsul import example.json
```

To import into an alternate prefix the following needs to be done:

```sh
jsonconsul import -prefix='vsco/buzz' example.json
```

### Export

There are five ways to run `jsonconsul export`. There are:

 - Output to STDOUT
 - Output to file
 - Output to file but timestamp the output file and symlink to name.
 - Poll and output to file after a duration.
 - Poll and output to file after a duration but with timestamped output file.

#### Output to STDOUT
```sh
jsonconsul export -prefix="foo"
```

If we don't want to include the prefix in the outputed json:
```sh
jsonconsul export -include-prefix=false -prefix="foo"
```

#### Output to file
```sh
jsonconsul export -prefix="foo" foo.json
{'fraction_non_alphanumeric': 0.12426268187180496, 'fraction_numerical': 0.0, 'mean_word_length': 4.412765957446808, 'pattern_counts': {'":': 14, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6283526', 'n_tokens_mistral': 803, 'n_tokens_neox': 769, 'n_words': 328}