~pi/aka

6ff09d6d97b51dbd5fa3ed33d40ae367c17a2cf7 — Paul Ivanov 1 year, 1 month ago f62ee32
add usage, and --help
2 files changed, 27 insertions(+), 8 deletions(-)

M README
M aka
M README => README +11 -4
@@ 1,7 1,12 @@
# Also Known As

A simple "launcher" of command-subcommand style where the the subcommands can
be altered based on configuration.
Simple, shell-based command aliasing

Usage: aka alias               show stored aliases
       aka alias NAME CMD...   store an alias for CMD
       aka NAME [...]          run CMD, optionally with more arguments

Examples:

    $ aka alias pager more



@@ 13,6 18,8 @@ be altered based on configuration.
    $ aka pager --version
    git version 2.28.0

Everything that is not aliased will get executed as usual.

## Notes

Initial prototype uses aliases, which may not work for programs that depend on


@@ 23,7 30,7 @@ We use an .aka file in the current directory for storing the aliases.

## Ideas

[ ] AKA_HOME environment variable to look for .aka (so we don't always look for
    .aka in either PWD or HOME)
[ ] AKA_HOME environment variable set to the directory containing the desired
    .aka file, otherwise we look for that file in the current directory.

[ ] `aka unalias` command

M aka => aka +16 -4
@@ 1,4 1,18 @@
#!/bin/sh
if [ $# -eq 0 ] ; then
    set -- -h # print usage on 0 arguments
fi

if [ $# -ge 1 ] ; then
    case $1 in
        -h|--help|-help|-H)
echo "Usage: aka alias               show stored aliases"
echo "       aka alias NAME CMD...   store an alias for CMD"
echo "       aka NAME [...]          run CMD, optionally with more arguments"
            exit 0
            ;;
    esac
fi

# Is this an alias creation? If so, we should have at least 3 arguments,
# such as:


@@ 20,12 34,10 @@ if [ $# -ge 3 ]  && [ $1 = alias ] ; then
    exit 0
fi

# Not an alias creation, let's load up aliases...
if [ -e .aka ] ; then
    # TODO - wrap this in if-VERBOSE
    #echo sourcing .aka;
    . ./.aka
fi

# TODO - wrap this in if-VERBOSE
#echo `type $1`
# Now execute command
eval $*