Giter VIP home page Giter VIP logo

shell_helpers's Introduction

shell_helpers

Gem Version Ruby test result Build Status

Description

This gem contains a collection of libraries to ease working with the shell with ruby.

A lot of the ideas here are inspired by the utilities in methadone. In particular logger.rb and sh.rb which were based on cli_logger.rb, cli_logging.rb, error.rb, exit_now.rb, process_status.rb, run.rb from methadone.

The reason to incorporate them in this gem is that I wanted to be able to add some functionalities (such as log_and_do for logger.rb, and on succes and on error callbacks for sh.rb), and also to be able to use this functionality from other command parsers than methadone (like gli).

Features

One of the main feature is an extension of the class Pathname with a lots of methods to help in shell related task.

Examples

~~~ ruby
require 'shell_helpers'
SH::Pathname.new("foo").cp("bar") #calls FileUtils.cp("foo","bar")
SH::Pathname.new("foo/").on_cp("bar","baz") #copy 'bar' and 'baz' to 'foo/'
SH::Pathname.new("foo").on_rm(mode: :dangling_symlink) #remove 'foo' only if it is a dangling symlink
SH::Pathname.new("foo").squel("bar/baz", action: :on_ln_s) #create a symlink foo/bar/baz -> ../../bar/baz

#Symlink all files in a directory into another, while preserving the structure
SH::Pathname.new("foo").squel_dir("bar',action: :on_ln_s)
#Remove these symlinks
SH::Pathname.new("foo").squel_dir("bar") {|o,t| o.on_rm(mode: :symlink)} 
~~~

Warning

For now the API is experimental and some parts are not ready to use!

Install

$ gem install shell_helpers

Copyright

Copyright ยฉ 2015โ€“2020 Damien Robert

MIT License. See LICENSE.txt for details.

See above for the copyright: for the files logger.rb and sh.rb the copyright applies only to the diff from the original import from methadone.

shell_helpers's People

Watchers

 avatar  avatar

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.