Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/dsingleton/bash-command-adaptor
- Owner: dsingleton
- Created: 2010-01-04T11:47:17.000Z (almost 15 years ago)
- Default Branch: master
- Last Pushed: 2010-01-18T12:37:31.000Z (almost 15 years ago)
- Last Synced: 2024-10-12T19:46:05.086Z (3 months ago)
- Homepage:
- Size: 78.1 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
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.