|
@@ -2288,65 +2288,78 @@ void __fastcall Usage(TConsole * Console)
|
|
|
Console->WaitBeforeExit();
|
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
|
-void __fastcall BatchSettings(TConsole * Console, TProgramParams * Params)
|
|
|
+int __fastcall HandleException(TConsole * Console, Exception & E)
|
|
|
{
|
|
|
- std::unique_ptr<TStrings> Arguments(new TStringList());
|
|
|
- if (DebugAlwaysTrue(Params->FindSwitch(L"batchsettings", Arguments.get())))
|
|
|
+ UnicodeString Message;
|
|
|
+ if (ExceptionFullMessage(&E, Message))
|
|
|
{
|
|
|
- if (Arguments->Count < 1)
|
|
|
- {
|
|
|
- Console->PrintLine(LoadStr(BATCH_SET_NO_MASK));
|
|
|
- }
|
|
|
- else if (Arguments->Count < 2)
|
|
|
+ Console->Print(Message);
|
|
|
+ }
|
|
|
+ return RESULT_ANY_ERROR;
|
|
|
+}
|
|
|
+//---------------------------------------------------------------------------
|
|
|
+int __fastcall BatchSettings(TConsole * Console, TProgramParams * Params)
|
|
|
+{
|
|
|
+ int Result = RESULT_SUCCESS;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ std::unique_ptr<TStrings> Arguments(new TStringList());
|
|
|
+ if (!DebugAlwaysTrue(Params->FindSwitch(L"batchsettings", Arguments.get())))
|
|
|
{
|
|
|
- Console->PrintLine(LoadStr(BATCH_SET_NO_SETTINGS));
|
|
|
+ Abort();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- TFileMasks Mask(Arguments->Strings[0]);
|
|
|
- Arguments->Delete(0);
|
|
|
+ if (Arguments->Count < 1)
|
|
|
+ {
|
|
|
+ throw Exception(LoadStr(BATCH_SET_NO_MASK));
|
|
|
+ }
|
|
|
+ else if (Arguments->Count < 2)
|
|
|
+ {
|
|
|
+ throw Exception(LoadStr(BATCH_SET_NO_SETTINGS));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ TFileMasks Mask(Arguments->Strings[0]);
|
|
|
+ Arguments->Delete(0);
|
|
|
|
|
|
- std::unique_ptr<TOptionsStorage> OptionsStorage(new TOptionsStorage(Arguments.get(), false));
|
|
|
+ std::unique_ptr<TOptionsStorage> OptionsStorage(new TOptionsStorage(Arguments.get(), false));
|
|
|
|
|
|
- int Matches = 0;
|
|
|
- int Changes = 0;
|
|
|
+ int Matches = 0;
|
|
|
+ int Changes = 0;
|
|
|
|
|
|
- for (int Index = 0; Index < StoredSessions->Count; Index++)
|
|
|
- {
|
|
|
- TSessionData * Data = StoredSessions->Sessions[Index];
|
|
|
- if (!Data->IsWorkspace &&
|
|
|
- Mask.Matches(Data->Name, false, false))
|
|
|
+ for (int Index = 0; Index < StoredSessions->Count; Index++)
|
|
|
{
|
|
|
- Matches++;
|
|
|
- std::unique_ptr<TSessionData> OriginalData(new TSessionData(L""));
|
|
|
- OriginalData->Assign(Data);
|
|
|
- Data->ApplyRawSettings(OptionsStorage.get());
|
|
|
- bool Changed = !OriginalData->IsSame(Data, false);
|
|
|
- if (Changed)
|
|
|
+ TSessionData * Data = StoredSessions->Sessions[Index];
|
|
|
+ if (!Data->IsWorkspace &&
|
|
|
+ Mask.Matches(Data->Name, false, false))
|
|
|
{
|
|
|
- Changes++;
|
|
|
+ Matches++;
|
|
|
+ std::unique_ptr<TSessionData> OriginalData(new TSessionData(L""));
|
|
|
+ OriginalData->Assign(Data);
|
|
|
+ Data->ApplyRawSettings(OptionsStorage.get());
|
|
|
+ bool Changed = !OriginalData->IsSame(Data, false);
|
|
|
+ if (Changed)
|
|
|
+ {
|
|
|
+ Changes++;
|
|
|
+ }
|
|
|
+ UnicodeString StateStr = LoadStr(Changed ? BATCH_SET_CHANGED : BATCH_SET_NOT_CHANGED);
|
|
|
+ Console->PrintLine(FORMAT(L"%s - %s", (Data->Name, StateStr)));
|
|
|
}
|
|
|
- UnicodeString StateStr = LoadStr(Changed ? BATCH_SET_CHANGED : BATCH_SET_NOT_CHANGED);
|
|
|
- Console->PrintLine(FORMAT(L"%s - %s", (Data->Name, StateStr)));
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- StoredSessions->Save(false, true); // explicit
|
|
|
- Console->PrintLine(FMTLOAD(BATCH_SET_SUMMARY, (Matches, Changes)));
|
|
|
+ StoredSessions->Save(false, true); // explicit
|
|
|
+ Console->PrintLine(FMTLOAD(BATCH_SET_SUMMARY, (Matches, Changes)));
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- Console->WaitBeforeExit();
|
|
|
}
|
|
|
-}
|
|
|
-//---------------------------------------------------------------------------
|
|
|
-int __fastcall HandleException(TConsole * Console, Exception & E)
|
|
|
-{
|
|
|
- UnicodeString Message;
|
|
|
- if (ExceptionFullMessage(&E, Message))
|
|
|
+ catch (Exception & E)
|
|
|
{
|
|
|
- Console->Print(Message);
|
|
|
+ Result = HandleException(Console, E);
|
|
|
}
|
|
|
- return RESULT_ANY_ERROR;
|
|
|
+
|
|
|
+ Console->WaitBeforeExit();
|
|
|
+ return Result;
|
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
|
bool __fastcall FindPuttygenCompatibleSwitch(
|
|
@@ -2683,7 +2696,7 @@ int __fastcall Console(TConsoleMode Mode)
|
|
|
if (CheckSafe(Params))
|
|
|
{
|
|
|
Configuration->Usage->Inc(L"BatchSettings");
|
|
|
- BatchSettings(Console, Params);
|
|
|
+ Result = BatchSettings(Console, Params);
|
|
|
}
|
|
|
}
|
|
|
else if (Mode == cmKeyGen)
|