Browse Source

Bug 1373: Name a session on command-line

https://winscp.net/tracker/1373

Source commit: 8aeb3523e601dde76c012b9727abc6cbac0a3f20
Martin Prikryl 10 years ago
parent
commit
2e4627593b

+ 1 - 0
source/core/Interface.h

@@ -6,6 +6,7 @@
 #include "SessionData.h"
 #define HELP_NONE ""
 #define COMMAND_SWITCH L"Command"
+#define SESSIONNAME_SWICH L"SessionName"
 //---------------------------------------------------------------------------
 TConfiguration * __fastcall CreateConfiguration();
 class TOptions;

+ 4 - 0
source/core/SessionData.cpp

@@ -1649,6 +1649,10 @@ bool __fastcall TSessionData::ParseUrl(UnicodeString Url, TOptions * Options,
     // as the option should not make session "connectable"
 
     UnicodeString Value;
+    if (Options->FindSwitch(SESSIONNAME_SWICH, Value))
+    {
+      Name = Value;
+    }
     if (Options->FindSwitch(L"privatekey", Value))
     {
       PublicKeyFile = Value;

+ 1 - 0
source/resource/TextsWin.h

@@ -268,6 +268,7 @@
 #define KEYGEN_PASSPHRASE2      1570
 #define KEYGEN_SAVED            1571
 #define USAGE_CERTIFICATE       1572
+#define USAGE_SESSIONNAME       1573
 
 #define WIN_FORMS_STRINGS       1600
 #define LOG_NOLOG               1601

+ 1 - 0
source/resource/TextsWin1.rc

@@ -271,6 +271,7 @@ BEGIN
         KEYGEN_PASSPHRASE2, "Re-enter passphrase to verify:"
         KEYGEN_SAVED, "Key saved to \"%s\"."
         USAGE_CERTIFICATE, "Fingerprint of server TLS/SSL certificate (FTPS protocol only)."
+        USAGE_SESSIONNAME, "Gives a name to the session"
 
         WIN_FORMS_STRINGS, "WIN_FORMS_STRINGS"
         LOG_NOLOG, "No session log."

+ 2 - 0
source/windows/ConsoleRunner.cpp

@@ -2052,6 +2052,7 @@ void __fastcall Usage(TConsole * Console)
   {
     PrintUsageSyntax(Console, L"site|workspace|folder");
     PrintUsageSyntax(Console, L"(sftp|scp|ftp[es]|http[s])://[user[:password]@]host[:port][/path/[file]]");
+    PrintUsageSyntax(Console, FORMAT(L"[mysession] /%s=<name>", (LowerCase(SESSIONNAME_SWICH))));
     PrintUsageSyntax(Console, L"[mysession] /newinstance");
     PrintUsageSyntax(Console, L"[mysession] /edit <path>");
     PrintUsageSyntax(Console, L"[mysession] /synchronize [local_dir] [remote_dir] [/defaults]");
@@ -2083,6 +2084,7 @@ void __fastcall Usage(TConsole * Console)
   if (!Console->CommandLineOnly())
   {
     RegisterSwitch(SwitchesUsage, L"session", USAGE_SESSION);
+    RegisterSwitch(SwitchesUsage, TProgramParams::FormatSwitch(SESSIONNAME_SWICH) + L"=", USAGE_SESSIONNAME);
     RegisterSwitch(SwitchesUsage, L"/newinstance", USAGE_NEWINSTANCE);
     RegisterSwitch(SwitchesUsage, L"/edit", USAGE_EDIT);
     RegisterSwitch(SwitchesUsage, L"/synchronize", USAGE_SYNCHRONIZE);