Skip to content

Commit

Permalink
Updated CL Help
Browse files Browse the repository at this point in the history
  • Loading branch information
panos1b committed Apr 20, 2024
1 parent 5993697 commit 2b57ee0
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,21 @@ static void Main(string[] args)
// This will display the help for the repository
if ("-h".Equals(args[0]) || "--help".Equals(args[0]))
{
Help.PrintHelp();
try
{
if (args.Length < 2)
{
Help.PrintHelp();
}
else
{
Help.PrintHelp(args[1]);
}
}
catch (IllegalArgumentExeption ex)
{
Console.WriteLine(ex.Message);
}
return;
}

Expand Down
44 changes: 44 additions & 0 deletions scr/Help.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,51 @@ public static void PrintHelp()
{
Console.WriteLine("This programm performs statistical analysis for a set of integers");
Console.WriteLine("usage: Program [--min] [--max] [--mode] [--mean] [--median] [--individual] [integer1 integer2 ...]");
Console.WriteLine("For more help on a spesific argument type --help and the argument. Like this: Program --help [--min] [--max] [--mode] [--mean] [--median] [--individual]");
Console.WriteLine("To print the full help type --help --all");
return;
}
public static void PrintHelp(String argument)
{
switch (argument)
{
case "--min":
Console.WriteLine("The --min argument finds the minimum value for a set of integers");
break;
case "--max":
Console.WriteLine("The --max argument finds the maximum value for a set of integers");
break;
case "--mode":
Console.WriteLine("The --mode argument finds the mode value for a set of integers");
Console.WriteLine("The mode is a measure of central tendency, meaning it's a value that represents a typical or central value within a set of data");
Console.WriteLine("Multimodal integer sets will return the first mode (which is lowest in value)");
break;
case "--mean":
Console.WriteLine("The --mean argument finds the mean value for a set of integers");
Console.WriteLine("The mean, often referred to as the average, is a measure of central tendency in statistics");
break;
case "--median":
Console.WriteLine("The --median argument finds the average value for a set of integers");
Console.WriteLine("The median is another measure of central tendency in statistics.\nThe median is the middle value of a dataset when it's ordered from least to greatest");
break;
case "--individual":
Console.WriteLine("The --individual argument keeps only unique values for a set of integers");
Console.WriteLine("That means that the passed values '1 2 3' and '1 2 2 2 2 2 2 3' are the same");
break;
case "--all":
// Prints all the helps via a recursive call
string[] arguments = new string[] { "--min", "--max", "--mode", "--mean", "--median", "--individual" };
foreach (String arg in arguments)
{
Console.WriteLine($"---------------------------------------------\n{arg}:");
PrintHelp(arg);
}
Console.WriteLine($"---------------------------------------------");
break;
default:
// This means they gave a wrong second argument
throw new IllegalArgumentExeption("Invalid Argument. Type -h or --help for help");
}
}
}
}

0 comments on commit 2b57ee0

Please sign in to comment.