[videodb] remove unused seasons table from episode_view
[xbmc.git] / xbmc / application / AppParamParser.cpp
blob20b54e7869c5feb26f76e68fb3c310ca3c756dfb
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #include "AppParamParser.h"
11 #include "CompileInfo.h"
12 #include "FileItem.h"
13 #include "FileItemList.h"
14 #include "ServiceBroker.h"
15 #include "application/AppParams.h"
16 #include "utils/StringUtils.h"
17 #include "utils/SystemInfo.h"
18 #include "utils/log.h"
20 #include <iostream>
21 #include <stdlib.h>
22 #include <string>
24 namespace
27 constexpr const char* versionText =
28 R"""({0} Media Center {1}
29 Copyright (C) {2} Team {0} - http://kodi.tv
30 )""";
32 constexpr const char* helpText =
33 R"""(Usage: {0} [OPTION]... [FILE]...
35 Arguments:
36 -fs Runs {1} in full screen
37 --standalone {1} runs in a stand alone environment without a window
38 manager and supporting applications. For example, that
39 enables network settings.
40 -p or --portable {1} will look for configurations in install folder instead of ~/.{0}
41 --debug Enable debug logging
42 --version Print version information
43 --test Enable test mode. [FILE] required.
44 --settings=<filename> Loads specified file after advancedsettings.xml replacing any settings specified
45 specified file must exist in special://xbmc/system/
46 )""";
48 } // namespace
50 CAppParamParser::CAppParamParser() : m_params(std::make_shared<CAppParams>())
54 void CAppParamParser::Parse(const char* const* argv, int nArgs)
56 std::vector<std::string> args;
57 args.reserve(nArgs);
59 for (int i = 0; i < nArgs; i++)
61 args.emplace_back(argv[i]);
62 if (i > 0)
63 ParseArg(argv[i]);
66 if (nArgs > 1)
68 // testmode is only valid if at least one item to play was given
69 if (m_params->GetPlaylist().IsEmpty())
70 m_params->SetTestMode(false);
73 // Record raw paramerters
74 m_params->SetRawArgs(std::move(args));
77 void CAppParamParser::DisplayVersion()
79 std::cout << StringUtils::Format(versionText, CSysInfo::GetAppName(), CSysInfo::GetVersion(),
80 CCompileInfo::GetCopyrightYears());
81 exit(0);
84 void CAppParamParser::DisplayHelp()
86 std::string lcAppName = CSysInfo::GetAppName();
87 StringUtils::ToLower(lcAppName);
89 std::cout << StringUtils::Format(helpText, lcAppName, CSysInfo::GetAppName());
92 void CAppParamParser::ParseArg(const std::string &arg)
94 if (arg == "-fs" || arg == "--fullscreen")
95 m_params->SetStartFullScreen(true);
96 else if (arg == "-h" || arg == "--help")
98 DisplayHelp();
99 exit(0);
101 else if (arg == "-v" || arg == "--version")
102 DisplayVersion();
103 else if (arg == "--standalone")
104 m_params->SetStandAlone(true);
105 else if (arg == "-p" || arg == "--portable")
106 m_params->SetPlatformDirectories(false);
107 else if (arg == "--debug")
108 m_params->SetLogLevel(LOG_LEVEL_DEBUG);
109 else if (arg == "--test")
110 m_params->SetTestMode(true);
111 else if (arg.substr(0, 11) == "--settings=")
112 m_params->SetSettingsFile(arg.substr(11));
113 else if (arg.length() != 0 && arg[0] != '-')
115 const CFileItemPtr item = std::make_shared<CFileItem>(arg);
116 item->SetPath(arg);
117 m_params->GetPlaylist().Add(item);