Giter VIP home page Giter VIP logo

yh's Introduction

yh - YAML Highlighter

A dummy syntax highlighter that brings colours to YAML output, jq style.

This project starts with the author's incapacity to give up on colours while playing with kubernetes cli and YAML output (kubectl get something -o yaml).

Unable to find another YAML highlighter where he could simply dump something on, with little to no respect expectations, and inspired by the recent Go training, he decided to write one from scratch.

Comparison with or without yh

How to use

As easy as you secretly hoped

kubectl get pod alpine -o yaml | yh

Other commands:

  • yh help
  • yh version

Download & installation

Find the latest releases here:

Brew

brew install yh

Linux or MacOS

Unzip

unzip yh-<os>-<arch>.zip

Move the binary somewhere in your PATH

mv yh /usr/local/bin/

Windows

Like above but with your mouse

Future developments

The aim of this project is to be a simple highlighting tool, while there are more featured projects our there to do YAML parsing. However I intend to keep maintaining the code and introduce new features and/or explore different routes in the future. Anyone thinking to contribute or make suggestions/requests would be more than welcome.

yh's People

Contributors

andreazorzetto avatar sh0rez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yh's Issues

Comments should be highlighted as a different color

It's a bit odd that comments don't have a different color. Oddly enough, the code is there to make it happen but it's not working

yh/highlight/highlight.go

Lines 114 to 116 in df5758b

func comment(l yamlLine) string {
return fmt.Sprintf("%v %v\n", Gray(13, l.key), Gray(13, l.value))
}

If there's any interest in accepting a patch for this, appreciate your replies on this issue.

image

Swallows comment-only lines

Input:

spec:
  # comment1
  progressDeadlineSeconds: 600
  # comment2
  replicas: 3
  # comment3
  revisionHistoryLimit: 10

Output:
image

Can I highlight kustomize output (yaml)

Somehow I cant get the output of kustomize get highlighted:

kustomize build k8s/kustomize/overlays/dev | yh

output: zsh: command not found:  yh

but using with kubectl works: kubectl get all -o yaml | yh

output is colorized:

apiVersion: v1
items:
- apiVersion: v1
  kind: Pod

I am using BigSur MacOS

Make color scheme used configurable

It would be great to make the color scheme configurable, so it's possible to use e.g. the same color scheme which vim uses.

The alternative is to use vim directly, like: vim -c 'set syntax=yaml' -R -.

arm builds?

Hi,

Is it possible to provide arm builds as part of the releases?

panic: "index out of range [0] with length 0" during kubectl get configmap

For the following .yaml;

apiVersion: v1
data:
  foo.conf: "consul-api:\n  sync: \"true\"\nvault:\n  sync: \"true\"\n  consul-filter
    : '(Service.Tags contains \"active\")'\netcd:\n  sync: \"true\"\n  consul-filter:
    '(Service.Tags contains \"_cluster=baz\")'\netcd-node-exporter:\n"
kind: ConfigMap
metadata:
  name: foo-services
  namespace: bar
  selfLink: /api/v1/namespaces/external/configmaps/foo-services

Returns panic:

$ cat foo.yml | yh

apiVersion: v1
data:
  foo.conf: "consul-api:\n  sync: \"true\"\nvault:\n  sync: \"true\"\n  consul-filter
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
main.main()
	/Users/andreazorzetto/go/src/yh/main.go:59 +0x151a

Version:

$ yh version

0.2.1

Homebrew Formulae

It would be awesome to have the possibility to install this neat little tool via Brew.
I've never initiated a formulae for brew but if nobody else would do, I would see what I can do!

Don't reorder empty lines

Given the following test file:

test: passed

anotherTest: failed

The expected output should contain the empty line between the two keys. Bu the actual output is:


test: passed
anotherTest: failed

Which is not what I expect. Either remove empty lines or keep them where they should be.

If there are more empty lines, they all moved to the beginning of the output.

YH version: 0.4.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.