Giter Club home page Giter Club logo

yaml-path's Introduction

Table of Contents

What

yaml-path reads given yaml on stdin and output a sort of 'path' corresponding to given line and column in the file.

Generated path is compilant with BOSH ops-file syntax.

Why ?

Working with BOSH often require to writes so-called ops-file which are kind of patches for yaml files. Writing the path of the object to modify is a real burden in large yaml files.

This tool is meant to be easily integrated in editor such as emacs.

Usage

usage: yaml-path [<flags>]

Flags:
  -h, --help         Show context-sensitive help (also try --help-long and --help-man).
      --line=0       Cursor line
      --col=0        Cursor column
      --sep="/"      Set path separator
      --name="name"  Set attribut name, empty to disable
      --path=""      Set filepath, empty means stdin
      --version      Show application version.

Example

Given the following yaml file:

top:
  first:
    - name: myname
      attr1: val1
      attr2: val2
      #       ^
    - value2
    - value3
  second:
    child1: value1
    child1: value2
    child3: value3

cat test.yaml | ./yaml-path --line 5 --col 14

Outputs:

/top/first/name=myname/attr2

Integration

Emacs

Get a local copy of this repo :

git clone https://github.com/psycofdj/yaml-path.git

Install emacs yaml-path package:

cd emacs && make install

Provided functions:

  • yaml-path-at-point : (interactive) display in minibuffer and store to kill ring yaml path for token under cursor
  • yaml-path-get-path-at-point(&optional line col) : return yaml path for token in current buffer at given line and column
  • yaml-path-which-func: integrates yaml-path-get-path-at-point with which-function-mode

Demo:

Demo

Vim

Install vim script (see the README):

cat ./plugin/yaml-path.vim >> ~/.vimrc

Demo:

Demo

Intellij

  1. Go to preference -> tools -> external tools
  2. Add a new one with this configuration

Demo

Note

The current implementation relies on a very savage hack of golang yaml library vendored in this project.

yaml-path's People

Contributors

arthurhlt avatar psycofdj avatar romain-dartigues avatar

Stargazers

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

Watchers

 avatar  avatar

Forkers

arthurhlt jceb

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.