Skip to content

Commit

Permalink
Add README
Browse files Browse the repository at this point in the history
  • Loading branch information
praveenperera committed Jul 5, 2021
1 parent 392f241 commit 0804791
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 7 deletions.
137 changes: 137 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# yamine [![Mean Bean CI](https://github.com/avencera/yamine/workflows/Mean%20Bean%20CI/badge.svg)](https://github.com/avencera/yamine/actions?query=workflow%3A%22Mean+Bean+CI%22)

A simple CLI for combining json and yaml files

## Install

Available via Homebrew/Linuxbrew

`brew install avencera/yamine/yamine`

or

Install from a github release:

`curl -LSfs https://avencera.github.io/yamine/install.sh | sh -s -- --git avencera/yamine`

or

Download a release directly from github: [github.com/avencera/yamine/releases](https://github.com/avencera/yamine/releases)

## Usage

`yamine --help`

```
Combine JSON/YAML files into a single YAML file
USAGE:
yamine [FLAGS] [OPTIONS] <FILES_OR_FOLDERS>...
FLAGS:
--dry-run Default mode
-h, --help Prints help information
-s, --std-out Outputs combined file contents to STDOUT
-V, --version Prints version information
-w, --write Write new output file
OPTIONS:
-d, --depth <depth> Number of folder depth to recurse into [default: 1]
-f, --format <format> The format for the output file, defaults to yaml, options are: 'yaml', 'json', 'k8s-json'
[default: yaml]
-o, --output <output> Output file name [default: combined.yaml]
ARGS:
<FILES_OR_FOLDERS>... File(s) or folder you want to run in
```

### Examples

- Combine all yaml and json files in the current folder and creates `combined.yaml` file
- `yamine -w .`
- Combine all yaml and json files in the current folder and creates a `combined.json` file in `json-k8s` format:
- `yamine --write --format json-k8s --output combined.json .`
- Output the combined file to STDOUT in json-array format:
- `yamine --std-out -f json-array .`

### Formats

- `yaml` - a multi document yaml file separated by `---` (a kubernetes multi resource document)

```yaml
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
---
apiVersion: v1
kind: Namespace
metadata:
name: example
---
kind: ServiceAccount
apiVersion: v1
---
apiVersion: v1
kind: Service
---
apiVersion: apps/v1
kind: Deployment
```
- `json-array` - a json file with each combined file being an element in the array

```json
[
{
"apiVersion": "traefik.containo.us/v1alpha1",
"kind": "IngressRoute"
...
},
{
"apiVersion": "v1",
"kind": "Namespace",
...
},
{
"apiVersion": "v1",
"kind": "ServiceAccount",
...
},
{
"apiVersion": "v1",
"kind": "Service",
...
},
]
```

- `json-k8s` - a kubernetes multi resource json document ex:

```json
{
"kind": "List",
"apiVersion": "v1",
"items": [
{
"apiVersion": "traefik.containo.us/v1alpha1",
"kind": "IngressRoute"
...
},
{
"apiVersion": "v1",
"kind": "Namespace",
...
},
{
"apiVersion": "v1",
"kind": "ServiceAccount",
...
},
{
"apiVersion": "v1",
"kind": "Service",
...
},
]
}
```
2 changes: 2 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ impl App {
{}
The combined file be created at: {}/{}
The combined file will be in `{}` format
To create the file run again in write mode using `{}` or `{}`.
To output the file to STDOUT use `{}` or `{}`
Expand All @@ -98,6 +99,7 @@ impl App {
files.white().dimmed(),
std::env::current_dir()?.to_string_lossy().green(),
self.output.green(),
self.format.to_string().green(),
"--write".green(),
"-w".green(),
"--std-out".green(),
Expand Down
14 changes: 7 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl FromStr for Format {
pub(crate) struct CliArgs {
#[structopt(
name = "FILES_OR_FOLDERS",
help = "file(s) or folder you want to run in",
help = "File(s) or folder you want to run in",
min_values = 1,
required = true
)]
Expand All @@ -47,32 +47,32 @@ pub(crate) struct CliArgs {
long,
short,
default_value = "1",
help = "number of folder depth to recurse into"
help = "Number of folder depth to recurse into"
)]
pub(crate) depth: usize,

#[structopt(
default_value = "combined.yaml",
short,
long,
help = "output file name"
help = "Output file name"
)]
pub(crate) output: String,

#[structopt(long, help = "default mode")]
#[structopt(long, help = "Default mode")]
pub(crate) dry_run: bool,

#[structopt(long, short, help = "write new output file")]
#[structopt(long, short, help = "Write new output file")]
pub(crate) write: bool,

#[structopt(long, short, help = "outputs combined file contents to STDOUT")]
#[structopt(long, short, help = "Outputs combined file contents to STDOUT")]
pub(crate) std_out: bool,

#[structopt(
long,
short,
default_value,
help = "the format for the output file, defaults to yaml, options are: 'yaml', 'json', 'k8s-json'"
help = "The format for the output file, defaults to yaml, options are: 'yaml', 'json', 'k8s-json'"
)]
pub(crate) format: Format,
}
Expand Down

0 comments on commit 0804791

Please sign in to comment.