mirror of
				https://github.com/cmderdev/cmder.git
				synced 2025-11-01 01:42:17 +08:00 
			
		
		
		
	better command line error handling
This commit is contained in:
		| @@ -247,6 +247,18 @@ void StartCmder(std::wstring  path = L"", bool is_single_mode = false, std::wstr | ||||
| 		} | ||||
| 		else // '/c [path]' was specified, don't copy anything and use existing conemu-%COMPUTERNAME%.xml to start comemu. | ||||
| 		{ | ||||
| 			if (use_user_cfg == false && PathFileExists(cfgPath) && !PathFileExists(cpuCfgPath)) // vendor/conemu-maximus5/ConEmu.xml file exists, copy vendor/conemu-maximus5/ConEmu.xml to config/ConEmu-%COMPUTERNAME%.xml. | ||||
| 			{ | ||||
| 				if (!CopyFile(cfgPath, cpuCfgPath, FALSE)) | ||||
| 				{ | ||||
| 					MessageBox(NULL, | ||||
| 						(GetLastError() == ERROR_ACCESS_DENIED) | ||||
| 						? L"Failed to copy vendor/conemu-maximus5/ConEmu.xml file to config/ConEmu-%COMPUTERNAME%.xml! Access Denied." | ||||
| 						: L"Failed to copy vendor/conemu-maximus5/ConEmu.xml file to config/ConEmu-%COMPUTERNAME%.xml!", MB_TITLE, MB_ICONSTOP); | ||||
| 					exit(1); | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			PathCombine(userConEmuCfgPath, userConfigDirPath, L"ConEmu-%COMPUTERNAME%.xml"); | ||||
| 			ExpandEnvironmentStrings(userConEmuCfgPath, userConEmuCfgPath, sizeof(userConEmuCfgPath) / sizeof(userConEmuCfgPath[0])); | ||||
| 		} | ||||
| @@ -504,6 +516,7 @@ cmderOptions GetOption() | ||||
| 	{ | ||||
|  | ||||
| 		// MessageBox(NULL, szArgList[i], L"Arglist contents", MB_OK); | ||||
| 		if (cmderOptions.error == false) { | ||||
| 			if (_wcsicmp(L"/c", szArgList[i]) == 0) | ||||
| 			{ | ||||
| 				TCHAR userProfile[MAX_PATH]; | ||||
| @@ -592,7 +605,8 @@ cmderOptions GetOption() | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 				MessageBox(NULL, szArgList[i], L"Folder does not exist!", 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\nor\n\n    /register [USER | ALL]\n\nor\n\n    /unregister [USER | ALL]\n", MB_TITLE, MB_OK); | ||||
| 					cmderOptions.error = true; | ||||
| 				} | ||||
| 			} | ||||
| 			else | ||||
| @@ -601,6 +615,7 @@ cmderOptions GetOption() | ||||
| 				cmderOptions.error = true; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	LocalFree(szArgList); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user