yutil

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2021 License: MIT Imports: 1 Imported by: 0

README

yutil

Test Status Lint Status Codecov report Conventional Commits MIT License

Common functionality for working with YAML files

Table of contents

Features

Getting started

Installation

Install yutil with your preferred method:

deb/rpm/apk:

Download the .deb, .rpm or .apk from the latest release and install them with the appropriate tools.

Manual

Download the .tar.gz from the latest release and add the binary to your path.

Go users
go install github.com/amplia-iiot/yutil@latest
Test installation
yutil version
Quick Start
yutil help
Merge

This outputs a formatted (ordered and cleaned) YAML file resulting of merging the passed yaml files (or content).

The files are merged in ascending level of importance in the hierarchy. A yaml node in the last file replaces values in any previous file. You may pass as many YAML files as desired:

yutil merge base.yml changes.yml
yutil merge base.yml changes.yml important.yml

Use -o (--output) option if you want to output to a file instead of stdout.

yutil merge base.yml changes.yml -o merged.yml

By default yutil uses stdin as the first YAML content:

cat base.yml | yutil merge changes.yml > merged.yml

You may ignore this input if you can't control what's piped to yutil:

echo "this is not a yaml" | yutil --no-input merge base.yml changes.yml
External configuration

You may want to always use the same config without writting the flags, yutil reads a YAML file to configure itself from the current folder or the user home dir in these order of precedence:

  • .yutil.yaml in current folder
  • .yutil.yml in current folder
  • .yutil in current folder
  • .yutil.yaml in user home dir
  • .yutil.yml in user home dir
  • .yutil in user home dir

Sample configuration file:

# Disable stdin
no-input: true
# Merge specific config
merge:
  # Merge output file
  output: /tmp/merged.yml

You may pass as argument the desired config file:

# Including extension to support multiple config types
./yutil version --config config.properties

Supported formats: JSON, TOML, YAML, HCL, envfile and Java properties config files

Development

  1. Use Golang version >= 1.16
  2. Fork (https://github.com/amplia-iiot/yutil)
  3. Run make set-up to install dev tools
  4. Create a feature branch
  5. Check changes (test & lint) with make check
  6. Commit your changes following Conventional Commits
  7. Rebase your local changes against the upstream main branch
  8. Create a Pull Request

You are welcome to report bugs or add feature requests and comments in issues.

Release Process

make version contains the steps to generate a new version. It uses svu to calculate the next version number based on the git log and generates the CHANGELOG.md with git-chglog

Push the generated tag and the release github action will generate the release.

CHANGELOG

See CHANGELOG.md

License

MIT © amplia-iiot

Documentation

Overview

Copyright (c) 2021 amplia-iiot

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Directories

Path Synopsis
internal
io
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL