Added deprecated args handling #4570

This commit is contained in:
XinyuHou 2015-05-06 11:57:42 +01:00
parent 4af987e8de
commit c168721d2f
3 changed files with 69 additions and 0 deletions

View File

@ -44,6 +44,9 @@ ArgParser::parseServerArgs(ServerArgs& args, int argc, const char* const* argv)
else if (parseGenericArgs(argc, argv, i)) { else if (parseGenericArgs(argc, argv, i)) {
continue; continue;
} }
else if (parseDeprecatedArgs(argc, argv, i)) {
continue;
}
else if (isArg(i, argc, argv, "-a", "--address", 1)) { else if (isArg(i, argc, argv, "-a", "--address", 1)) {
// save listen address // save listen address
args.m_synergyAddress = argv[++i]; args.m_synergyAddress = argv[++i];
@ -79,6 +82,9 @@ ArgParser::parseClientArgs(ClientArgs& args, int argc, const char* const* argv)
else if (parseGenericArgs(argc, argv, i)) { else if (parseGenericArgs(argc, argv, i)) {
continue; continue;
} }
else if (parseDeprecatedArgs(argc, argv, i)) {
continue;
}
else if (isArg(i, argc, argv, NULL, "--camp")) { else if (isArg(i, argc, argv, NULL, "--camp")) {
// ignore -- included for backwards compatibility // ignore -- included for backwards compatibility
} }
@ -297,6 +303,18 @@ ArgParser::parseGenericArgs(int argc, const char* const* argv, int& i)
return true; return true;
} }
bool
ArgParser::parseDeprecatedArgs(int argc, const char* const* argv, int& i)
{
if (isArg(i, argc, argv, NULL, "--crypto-pass")) {
LOG((CLOG_NOTE "--crypto-pass is deprecated"));
i++;
return true;
}
return false;
}
bool bool
ArgParser::isArg( ArgParser::isArg(
int argi, int argc, const char* const* argv, int argi, int argc, const char* const* argv,

View File

@ -36,6 +36,7 @@ public:
bool parsePlatformArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i); bool parsePlatformArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i);
bool parseToolArgs(ToolArgs& args, int argc, const char* const* argv); bool parseToolArgs(ToolArgs& args, int argc, const char* const* argv);
bool parseGenericArgs(int argc, const char* const* argv, int& i); bool parseGenericArgs(int argc, const char* const* argv, int& i);
bool parseDeprecatedArgs(int argc, const char* const* argv, int& i);
void setArgsBase(ArgsBase& argsBase) { m_argsBase = &argsBase; } void setArgsBase(ArgsBase& argsBase) { m_argsBase = &argsBase; }
static bool isArg(int argi, int argc, const char* const* argv, static bool isArg(int argi, int argc, const char* const* argv,

View File

@ -0,0 +1,50 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2015 Synergy Si, Inc.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "synergy/ArgParser.h"
#include "test/global/gtest.h"
using namespace synergy;
TEST(DeprecatedArgsParsingTests, parseDeprecatedArgs_cryptoPass_returnTrue)
{
int i = 1;
const int argc = 3;
const char* kCryptoPassCmd[argc] = { "stub", "--crypto-pass", "mock_pass" };
ArgParser argParser(NULL);
bool result = argParser.parseDeprecatedArgs(argc, kCryptoPassCmd, i);
EXPECT_EQ(true, result);
EXPECT_EQ(2, i);
}
TEST(DeprecatedArgsParsingTests, parseDeprecatedArgs_cryptoPass_returnFalse)
{
int i = 1;
const int argc = 3;
const char* kCryptoPassCmd[argc] = { "stub", "--mock-arg", "mock_value" };
ArgParser argParser(NULL);
bool result = argParser.parseDeprecatedArgs(argc, kCryptoPassCmd, i);
EXPECT_EQ(false, result);
EXPECT_EQ(1, i);
}