From f9c6d61ee0eb6e9e162ef9d5f8642e02ebc9fa34 Mon Sep 17 00:00:00 2001 From: Vivix Date: Wed, 27 Nov 2013 04:36:48 +0100 Subject: [PATCH] Added minimal validation and usage help. --- bin/alias.bat | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/bin/alias.bat b/bin/alias.bat index 4b6e5d5..8e048ae 100644 --- a/bin/alias.bat +++ b/bin/alias.bat @@ -1,4 +1,28 @@ @echo off +if ["%1"] == ["/?"] goto:p_help +if ["%2"] == [""] echo Insufficient parameters. & goto:p_help +::validate alias +setlocal +for /f "delims== tokens=1" %%G in ("%*") do set _temp2=%%G + + set _temp=%_temp2: =% + +if not ["%_temp%"] == ["%_temp2%"] ( + echo Your alias name can not contain a space + endlocal + goto:eof +) + echo %* >> %~dp0..\config\aliases doskey /macrofile=%~dp0..\config\aliases echo Alias created +endlocal +goto:eof + +:p_help +echo.Usage: +echo. alias name=full command +echo. $* allows the alias to assume all the parameters of the supplied command. +echo. $1-$9 Allows you to seperate parameter by number, much like %%1 in batch. +echo. $T is the command seperator, allowing you to string several commands together into one alias. +echo. For more information, read DOSKEY/?