added exit codes

This commit is contained in:
Dax T. Games 2018-09-15 13:55:54 -05:00
parent 669e997602
commit 9dce9d0f62
3 changed files with 22 additions and 17 deletions

View File

@ -148,7 +148,7 @@ You may find some Monokai color schemes for mintty to match Cmder [here](https:/
| `/svn_ssh [path to ssh.exe]` | Define `%SVN_SSH%` so we can use git svn with ssh svn repositories. | `%GIT_INSTALL_ROOT%\bin\ssh.exe` |
| `/user_aliases [file path]` | File path pointing to user aliases. | `%CMDER_ROOT%\config\user-liases.cmd` |
| `/v` | Enables verbose output. | not set |
| (custom arguments) | User defined arguments processed by `flag_exists`. Type `%flag_exists% /?` for more useage. | not set |
| (custom arguments) | User defined arguments processed by `cexec`. Type `cexec /?` for more useage. | not set |
### Cmder Shell User Config
Single user portable configuration is possible using the cmder specific shell config files. Edit the below files to add your own configuration:
@ -249,7 +249,7 @@ Uncomment and edit the below line in the script to use Cmder config even when la
### Handling with custom arguments when using init.bat
You can pass custom arguments to `init.bat` and use `%flag_exists%` to detect it.
You can pass custom arguments to `init.bat` and use `cexec` to detect it.
It is useful when you have multiple modes to execute cmder.
@ -265,7 +265,7 @@ to start init.bat with custom argument(`/startNotepad`) and put
```batch
call %flag_exists% "/startNotepad" "start" "notepad.exe"`
call cexec "/startNotepad" "start" "notepad.exe"`
```
@ -279,7 +279,7 @@ init.bat
the `notepad.exe` won't be executed.
To see detailed usage of `%flag_exists%`, type `%flag_exists% /?` in cmder.
To see detailed usage of `cexec`, type `cexec /?` in cmder.
### Integrating Cmder with [Hyper](https://github.com/zeit/hyper), [Microsoft VS Code](https://code.visualstudio.com/), and your favorite IDEs

View File

@ -19,9 +19,10 @@ set "currenArgu=%~1"
if /i "%currenArgu%" equ "/setPath" (
:: set %flag_exists% shortcut
endlocal
set "flag_exists=%~dp0flag_exists"
set "ccall=call %~dp0cexec.cmd"
set "cexec=%~dp0cexec.cmd"
) else if /i "%currenArgu%" == "/?" (
goto :help
call :help
) else if /i "%currenArgu%" equ "/help" (
goto :help
) else if /i "%currenArgu%" equ "/h" (
@ -55,14 +56,16 @@ echo %CMDER_USER_FLAGS% | find /i "%feFlagName%">nul
if "%ERRORLEVEL%" == "0" (
if "%feNOT%" == "false" (
call %feCommand% %feParam%
exit /b 0
)
) else (
if "%feNOT%" == "true" (
call %feCommand% %feParam%
exit /b 0
)
)
endlocal
exit /b
exit /b 1
:wrongSyntax
echo The syntax of the command is incorrect.
@ -74,22 +77,22 @@ exit /b
:help
echo.
echo %%flag_exists%%
echo CExec - Conditional Exec
echo.
echo Handles with custom arguments for cmder's init.bat.
echo written by xiazeyu, inspired DRSDavidSoft.
echo.
echo Usage:
echo.
echo %%flag_exists%% [/setPath] [NOT] flagName command/program [parameters]
echo cexec [NOT] flagName command/program [parameters]
echo.
echo setPath Generate a global varible %%flag_exists%% for
echo /setPath Generate a global varible %%cexec%% for
echo quicker use. Following arguments will be ignored.
echo.
echo NOT Specifies that %%flag_exists%% should carry out
echo NOT Specifies that cexec should carry out
echo the command only if the flag is missing.
echo.
echo flagName Specifies which flag name is to detect. It's recommand
echo /[flagName] Specifies which flag name is to detect. It's recommand
echo to use a pair of double quotation marks to wrap
echo your flag name to avoid exceed expectation.
echo.
@ -104,16 +107,17 @@ echo to wrap your flag name to avoid exceed expectation.
echo.
echo Examples:
echo.
echo these examples are expected to be writted in /config/user-profile.cmd
echo it will use the environment varible "CMDER_USER_FLAGS"
echo These examples are expected to be written in %cmder_root%/config/user-profile.cmd
echo CExec evaluates the environment varible "CMDER_USER_FLAGS" and conditionally
echo caries out actions based on flags that are passed.
echo.
echo Case 1:
echo.
echo The following command in user-profile.cmd would execute "notepad.exe"
echo.
echo call %%flag_exists%% "/startNotepad" "start" "notepad.exe"
echo call cexec "/startNotepad" "start" "notepad.exe"
echo.
echo if you pass parameter to init.bat like:
echo If you pass parameter to init.bat like:
echo.
echo init.bat /startNotepad
echo.
@ -121,7 +125,7 @@ echo Case 2:
echo.
echo The following command in user-profile.cmd would execute "notepad.exe"
echo.
echo call %%flag_exists%% NOT "/dontStartNotepad" "start" "notepad.exe"
echo call cexec NOT "/dontStartNotepad" "start" "notepad.exe"
echo.
echo UNLESS you pass parameter to init.bat like:
echo.

1
vendor/init.bat vendored
View File

@ -29,6 +29,7 @@ if not defined CMDER_ROOT (
:: Remove trailing '\' from %CMDER_ROOT%
if "%CMDER_ROOT:~-1%" == "\" SET "CMDER_ROOT=%CMDER_ROOT:~0,-1%"
call "%cmder_root%\vendor\bin\cexec.cmd" /setpath
call "%cmder_root%\vendor\lib\lib_base"
call "%cmder_root%\vendor\lib\lib_path"
call "%cmder_root%\vendor\lib\lib_console"