Skip to content

Instantly share code, notes, and snippets.

@LuckyTeng
Created September 8, 2018 00:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LuckyTeng/6ecafa872e89ac9f01a244c2121c4b26 to your computer and use it in GitHub Desktop.
Save LuckyTeng/6ecafa872e89ac9f01a244c2121c4b26 to your computer and use it in GitHub Desktop.
check_verbs
@echo off
setlocal enableDelayedExpansion
if not defined bin (
:: set bin to current directory
set bin=%~dp0
)
echo current dir %bin%
set verbs=;open;delete;version;
echo checking verb...
call:checkMatch "%verbs%" %* || (
echo.
echo verb is ok
exit /b 0
)
echo invalid verb, ava is open, delete, version
exit /b 1
:checkMatch
set verbs=%~1
set verb=""
shift
:loop
if "%~1"=="" ( goto:done )
set arg=%~1
shift
echo arg is %arg%
if "%arg:~0,1%"=="-" ( goto:loop )
if !verb!=="" if "!verbs:;%arg%;=!" neq "!verbs!" (
echo find verb !arg!
set verb=!arg!
goto:loop
)
:done
if !verb! neq "" exit /b 1
exit /b 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment