Merge pull request #2096 from eziosella/pull-request-2094-pars-forwarding

Add `/x "CONEMU ARGS"` command line argument.
This commit is contained in:
Dax T Games 2019-05-22 08:30:18 -07:00 committed by GitHub
commit 4510abb3c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 4 deletions

View File

@ -2,6 +2,12 @@
## [Unreleased]
* Question issue: [#2094](https://github.com/cmderdev/cmder/issues/2094)
* Pull Request : [#2096](https://github.com/cmderdev/cmder/pull/2096)
* New argument created to ConEmu forwarding arguments.
* Syntax: `/x [ConEmu extras arguments]`
* e.g.: `Cmder.exe /x "-min -tsa"`
### Fixes
* Pull Request: [#2002](https://github.com/cmderdev/cmder/pull/2002)

View File

@ -50,6 +50,7 @@ The Cmder's user interface is also designed to be more eye pleasing, and you can
| `/SINGLE` | Start Cmder in single mode. |
| `/START [start_path]` | Folder path to start in. |
| `/TASK [task_name]` | Task to start after launch. |
| `/X [ConEmu extras pars]` | Forwads parameters to ConEmu |
## Context Menu Integration

View File

@ -71,7 +71,7 @@ bool FileExists(const wchar_t * filePath)
return false;
}
void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstring taskName = L"", std::wstring cfgRoot = L"", bool use_user_cfg = true)
void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstring taskName = L"", std::wstring cfgRoot = L"", bool use_user_cfg = true, std::wstring conemu_args = L"")
{
#if USE_TASKBAR_API
wchar_t appId[MAX_PATH] = { 0 };
@ -98,6 +98,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
std::wstring cmderStart = path;
std::wstring cmderTask = taskName;
std::wstring cmderConEmuArgs = conemu_args;
std::copy(cfgRoot.begin(), cfgRoot.end(), userConfigDirPath);
userConfigDirPath[cfgRoot.length()] = 0;
@ -391,6 +392,11 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
swprintf_s(args, L"%s -loadcfgfile \"%s\"", args, userConEmuCfgPath);
}
if (!streqi(cmderConEmuArgs.c_str(), L""))
{
swprintf_s(args, L"%s %s", args, cmderConEmuArgs.c_str());
}
SetEnvironmentVariable(L"CMDER_ROOT", exeDir);
if (wcscmp(userConfigDirPath, configDirPath) != 0)
{
@ -527,6 +533,7 @@ struct cmderOptions
std::wstring cmderStart = L"";
std::wstring cmderTask = L"";
std::wstring cmderRegScope = L"USER";
std::wstring cmderConEmuArgs = L"";
bool cmderSingle = false;
bool cmderUserCfg = true;
bool registerApp = false;
@ -620,6 +627,12 @@ cmderOptions GetOption()
}
}
}
/* Used for passing arguments to conemu prog */
else if (_wcsicmp(L"/x", szArgList[i]) == 0)
{
cmderOptions.cmderConEmuArgs = szArgList[i + 1];
i++;
}
else if (cmderOptions.cmderStart == L"")
{
int len = wcslen(szArgList[i]);
@ -635,13 +648,13 @@ cmderOptions GetOption()
}
else
{
MessageBox(NULL, L"Unrecognized parameter.\n\nValid options:\n\n /c [CMDER User Root Path]\n\n /task [ConEmu Task Name]\n\n [/start [Start in Path] | [Start in Path]]\n\n /single\n\n /m\n\nor\n\n /register [USER | ALL]\n\nor\n\n /unregister [USER | ALL]\n", MB_TITLE, MB_OK);
MessageBox(NULL, L"Unrecognized parameter.\n\nValid options:\n\n /c [CMDER User Root Path]\n\n /task [ConEmu Task Name]\n\n [/start [Start in Path] | [Start in Path]]\n\n /single\n\n /m\n\n /x [ConEmu extra arguments]\n\nor\n\n /register [USER | ALL]\n\nor\n\n /unregister [USER | ALL]\n", MB_TITLE, MB_OK);
cmderOptions.error = true;
}
}
else
{
MessageBox(NULL, L"Unrecognized parameter.\n\nValid options:\n\n /c [CMDER User Root Path]\n\n /task [ConEmu Task Name]\n\n [/start [Start in Path] | [Start in Path]]\n\n /single\n\n /m\n\nor\n\n /register [USER | ALL]\n\nor\n\n /unregister [USER | ALL]\n", MB_TITLE, MB_OK);
MessageBox(NULL, L"Unrecognized parameter.\n\nValid options:\n\n /c [CMDER User Root Path]\n\n /task [ConEmu Task Name]\n\n [/start [Start in Path] | [Start in Path]]\n\n /single\n\n /m\n\n /x [ConEmu extra arguments]\n\nor\n\n /register [USER | ALL]\n\nor\n\n /unregister [USER | ALL]\n", MB_TITLE, MB_OK);
cmderOptions.error = true;
}
}
@ -683,7 +696,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
}
else
{
StartCmder(cmderOptions.cmderStart, cmderOptions.cmderSingle, cmderOptions.cmderTask, cmderOptions.cmderCfgRoot, cmderOptions.cmderUserCfg);
StartCmder(cmderOptions.cmderStart, cmderOptions.cmderSingle, cmderOptions.cmderTask, cmderOptions.cmderCfgRoot, cmderOptions.cmderUserCfg, cmderOptions.cmderConEmuArgs);
}
return 0;