Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dsingleton/bash-command-adaptor

A simple way to wrap a system command and add or enhance functionality
https://github.com/dsingleton/bash-command-adaptor

Last synced: about 1 month ago
JSON representation

A simple way to wrap a system command and add or enhance functionality

Awesome Lists containing this project

README

        

A simple way to wrap a system command and add or enhance functionality, Requiring minimal setup and using a clear and simple directory structure to add scripts.

This is a work in progress, and the example commands are just that, not meant for production.

== Install ==

To setup add /init to your bash init.

== How does this work? ==

It's best to look at the code for now. Or ask me. I'll write a better explanation later.

The init script creates an alias for each sub-directory mapped to a script of the same name, eg svn/svn or ls/ls.

In the current examples: ls is a single script wrapped around the native ls command, passing on all original arguments. You could, for example, log all ls path calls to a file ala bash history.

svn is a more complex example where the main script (svn/svn) delegates based on the sub-command, if a script of the same name exists (eg, "svn help" would map to svn/help) then it's called, otherwise the native sub command is called. The delegated script can then either implement new functionality or wrap native.

I need to define some better terminology to make this clearer.

=== Types of adaptor ===

Command adaptor: Wraps a single command, like "ls", allowing you to add new options or add to output.

Sub-command adaptor: Wraps a command with sub-commands, such as svn, allowing you to add new sub-commands locally.

== Warning ==

This is still a work in progress and needs some more re-factoring before it's ready for anyone else to use properly. Mostly making the delegation in svn/svn generic and not required in each script.

You should only add, never change, existing command functionality. Otherwise you'll likely break things relying on normal unix behavior. Don't be a dick.