@@ -29,7 +29,7 @@ void CommandArgs::Parse(_In_ LPCWSTR wszCommandLine)
2929 CommandParser parser;
3030 auto args = parser.Parse (wszCommandLine);
3131
32- m_path = parser.get_Path ();
32+ m_applicationPath = parser.get_Path ();
3333
3434 Parse (args);
3535}
@@ -39,13 +39,15 @@ void CommandArgs::Parse(_In_ int argc, _In_ LPCWSTR argv[])
3939 CommandParser parser;
4040 auto args = parser.Parse (argc, argv);
4141
42- m_path = parser.get_Path ();
42+ m_applicationPath = parser.get_Path ();
4343
4444 Parse (args);
4545}
4646
4747void CommandArgs::Parse (_In_ vector<CommandParser::Token> args)
4848{
49+ bool hasSelection = false ;
50+
4951 for (auto it = args.begin (); it != args.end (); ++it)
5052 {
5153 auto & arg = *it;
@@ -60,26 +62,32 @@ void CommandArgs::Parse(_In_ vector<CommandParser::Token> args)
6062 if (ArgumentEquals (arg.Value , L" all" ))
6163 {
6264 m_all = true ;
65+ hasSelection = true ;
6366 }
6467 else if (ArgumentEquals (arg.Value , L" products" ))
6568 {
6669 ParseArgumentArray (it, args.end (), arg, m_products);
70+ hasSelection = true ;
6771 }
6872 else if (ArgumentEquals (arg.Value , L" requires" ))
6973 {
7074 ParseArgumentArray (it, args.end (), arg, m_requires);
75+ hasSelection = true ;
7176 }
7277 else if (ArgumentEquals (arg.Value , L" requiresAny" ))
7378 {
7479 m_requiresAny = true ;
80+ hasSelection = true ;
7581 }
7682 else if (ArgumentEquals (arg.Value , L" version" ))
7783 {
7884 m_version = ParseArgument (it, args.end (), arg);
85+ hasSelection = true ;
7986 }
8087 else if (ArgumentEquals (arg.Value , L" latest" ))
8188 {
8289 m_latest = true ;
90+ hasSelection = true ;
8391 }
8492 else if (ArgumentEquals (arg.Value , L" sort" ))
8593 {
@@ -88,10 +96,16 @@ void CommandArgs::Parse(_In_ vector<CommandParser::Token> args)
8896 else if (ArgumentEquals (arg.Value , L" legacy" ))
8997 {
9098 m_legacy = true ;
99+ hasSelection = true ;
100+ }
101+ else if (ArgumentEquals (arg.Value , L" path" ))
102+ {
103+ m_path = ParseArgument (it, args.end (), arg);
91104 }
92105 else if (ArgumentEquals (arg.Value , L" prerelease" ))
93106 {
94107 m_prerelease = true ;
108+ hasSelection = true ;
95109 }
96110 else if (ArgumentEquals (arg.Value , L" format" ))
97111 {
@@ -170,6 +184,12 @@ void CommandArgs::Parse(_In_ vector<CommandParser::Token> args)
170184 {
171185 m_format = L" value" ;
172186 }
187+
188+ if (hasSelection && !m_path.empty ())
189+ {
190+ auto message = ResourceManager::GetString (IDS_E_PATHINCOMPATIBLE);
191+ throw win32_error (ERROR_INVALID_PARAMETER, message);
192+ }
173193}
174194
175195void CommandArgs::Usage (_In_ Console& console) const
0 commit comments