Skip to content

Commit 7256b71

Browse files
committed
fix bugs with empty flags -k, -f, -d
1 parent 3f685f2 commit 7256b71

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

SmartMove/CommandLine.cs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,12 @@ public CommandLine Parse(string[] args)
297297
case "-d":
298298
case "--domain":
299299
{
300-
if (args[i] != args.Last() && !args[i + 1].StartsWith("-"))
300+
if (args[i] == args.Last())
301+
{
302+
_successCommands = false;
303+
Console.WriteLine("Value for option -d is not specified! ", MessageTypes.Error);
304+
}
305+
else if(args[i] != args.Last() && !args[i + 1].StartsWith("-"))
301306
this.domain = args[i + 1];
302307
else
303308
{
@@ -357,13 +362,33 @@ public CommandLine Parse(string[] args)
357362
case "-k":
358363
case "--skip":
359364
{
360-
this.dontImportUnusedObjects = true;
365+
if (args[i] == args.Last())
366+
{
367+
_successCommands = false;
368+
Console.WriteLine("Value for option -k is not specified! ", MessageTypes.Error);
369+
}
370+
else if (args[i] != args.Last() && !args[i + 1].StartsWith("-"))
371+
{
372+
bool dontImportUnusedObjectsFlag;
373+
if (!bool.TryParse(args[i + 1], out dontImportUnusedObjectsFlag))
374+
{
375+
Console.WriteLine("Value for option -k is not corrected! Only true or false allowed ", MessageTypes.Error);
376+
_successCommands = false;
377+
}
378+
379+
this.dontImportUnusedObjects = dontImportUnusedObjectsFlag;
380+
}
361381
break;
362382
}
363383
case "-f":
364384
case "--format":
365385
{
366-
if (new List<string>() { "text", "json" }.Contains(args[i + 1].ToLower()))
386+
if (args[i] == args.Last())
387+
{
388+
_successCommands = false;
389+
Console.WriteLine("Value for option -f is not specified! ", MessageTypes.Error);
390+
}
391+
else if(new List<string>() { "text", "json" }.Contains(args[i + 1].ToLower()))
367392
FormatOutput = args[i + 1];
368393
else
369394
{

0 commit comments

Comments
 (0)