Giter Club home page Giter Club logo

yaml_command's Introduction

YAML COMMAND

Website / Report Issue / Development / IRC Channel

Description

YAML Command is a command line tool for working with YAML files.

While currently a work in progress, the goal is evolve the design for a standardized yaml command line tool. While this early implementation is written in Ruby, ultimately the final version would be written in C and be widely available.

IMPORTANT NOTE! YPath is not yet implemented so only simple name references can be used at this point.

Usage

Commands are invoked on the command line with:

$ yaml <command> [options...] [arguments...]

Commands

The following commands are currently supported:

  • get
    The get command simply extracts a portion of a YAML file and outputs it to stdout.

  • set
    The set command is the opposite of get in that it lets you change a portion of a YAML file. By default the changed YAML document will go to stdout, using the -s/--save option rewrites the file with the change.

  • sort
    The sort command can be used to sort portions of a YAML document.

  • slurp
    The slurp command takes a directory and converts it's contents into a YAML file.

  • splat
    The splat command takes a YAML file and converts it into a file directory structure. It is essentially the opposite of slurp.

  • edit
    Edit will open a YAML file for editing in the default editor (as defined by $EDITOR), and allow you to edit it.

    If instead you edit a directory, then the directory will be automatically slurped into a temporary file. After editing the temporary file will be splatted back out to update the directory and it's files.

  • view
    Outputs a colorized rendering of the YAML file.

Options

Some commands has special options. Use yaml <command> --help to learn about those. All (or nearly all) commands support the following options.

  • -F / --file [PATH]
    Use the given YAML file instead of using stdin.

  • -y / --yaml
    Output results in YAML format.

  • -j / --json
    Output results in JSON format.

  • -m / --mute
    Suppress all output.

  • -f / --force
    Used to force overwrites when necessary.

  • --debug
    Turn on debug mode to get detailed error report if there is a problem.

Installation

Ruby Interpreter

The yaml command is a Ruby script, so you will need a Ruby interpreter installed on your system. There are a few of these now, such as Rubinius, JRuby and the original MRI. The latter is the typical choice, and usually can be installed via your operating system's package manager. For example, on dpkg-based systems like Ubuntu, you can type in a shell console:

$ apt-get install ruby

Using RubyGems

With Ruby installed, the easiest way to install a Ruby library is via RubyGems. To install YAML Command just type:

$ gem install yaml_command

Requirements

YAML Command requires the following other packages be installed:

  • Executable library handle CLI parsing.
  • ANSI library provides console colorization.

If you are using RubyGems these will be install automatically.

Copyrights

Copyright (c) 2011 Rubyworks. All rights reserved.

YAML Command may be distributed in accordance with the BSD-2-Clause license.

See the LICENSE.txt file for details.

yaml_command's People

Contributors

trans avatar

Stargazers

 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

yaml_command's Issues

YPath not supported yet. (NotImplementedError)

Hey

I don't know if a usage error or missing feature. Do I use it correct?

yaml sort  xxx-targets.yml
Traceback (most recent call last):
	4: from /usr/local/bin/yaml:6:in `<main>'
	3: from /usr/local/bin/yaml:6:in `load'
	2: from /usr/local/Cellar/gem-yaml_command/0.1.1/gems/yaml_command-0.1.1/bin/yaml:4:in `<top (required)>'
	1: from /usr/local/Cellar/gem-yaml_command/0.1.1/gems/executable-1.2.1/lib/executable/domain.rb:100:in `execute'
/usr/local/Cellar/gem-yaml_command/0.1.1/gems/yaml_command-0.1.1/lib/yaml_command/sort.rb:22:in `call': YPath not supported yet. (NotImplementedError)

Need Tests!

Yes, this project was completely waterfalled.

Needs examples

Without example it's complicated to understand how to use for example the "set" command.
I tried:

yaml set analogist.image myvalue ./docker-compose.yml

without any success

Simplify CLI parsing

This is probably not the best project to use executable gem in. Using a #cli clap based method would be more fitting. We want this as tight as possible. (see Indexer project for cli code).

Minor typos in README.md

Re: README.md

splat
The splat command take a YAML file and converts it into a file directory structure. It is essentially the opposite of slurp.

[Change "take" to "takes".]

Ruby Interpreter

The yaml command is a Ruby script, so you will need a Ruby interpreter installed on your system. There are a few of these now, such as Rubinius, JRuby and the original MRI. The later is the typical choice, and usually can be installed via your operating system's package manager. For example, on dpkg-based systems like Ubuntu, you can type in a shell console:

[Change "later" to "latter".]

Copyrights

Copyright (c) 2011 Rubyworks. All rights reserved.

[Change "2011" to "2013"?]

README mentions --save, but no such option exists

In the README, for the set command, it mentions a --save/-s option, but that option is not yet implemented. It should be removed from the readme until it is implemented in order to save people time trying to use a feature that's not present.

"yaml view" should stop on invalid files

I can specify any text file as parameter to yaml view and it will just output it as-is, occasionally colouring lines which look like pieces of yaml

Is that intentional? I expected that it would give me something along the lines of "this file does not look like a valid YAML file"

Option Commands Instead?

Should the yaml command use more old-school style command line options, e.g. instead of yaml get it would be yaml -g.

dies on start

I just installed command using gem on OS X 10.8.2. I am using ruby 1.9.3-p327 from homebrew

[…]$ yaml 
/opt/homebrew/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/yaml_command-0.1.0/lib/yaml_command/base.rb:24:in `<class:Command>': undefined method `alias_switch' for YAMLCommand::Command:Class (NoMethodError)
    from /opt/homebrew/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/yaml_command-0.1.0/lib/yaml_command/base.rb:5:in `<module:YAMLCommand>'
    from /opt/homebrew/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/yaml_command-0.1.0/lib/yaml_command/base.rb:1:in `<top (required)>'
    from /opt/homebrew/Cellar/ruby/1.9.3-p327/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /opt/homebrew/Cellar/ruby/1.9.3-p327/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /opt/homebrew/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/yaml_command-0.1.0/lib/yaml_command.rb:4:in `<top (required)>'
    from /opt/homebrew/Cellar/ruby/1.9.3-p327/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /opt/homebrew/Cellar/ruby/1.9.3-p327/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /opt/homebrew/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/yaml_command-0.1.0/bin/yaml:2:in `<top (required)>'
    from /opt/homebrew/bin/yaml:23:in `load'
    from /opt/homebrew/bin/yaml:23:in `<main>'

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.