Skip to content

Commit

Permalink
Add -quiet/-q CLI option (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
RoadrunnerWMC authored Apr 9, 2024
1 parent 2a5f77c commit c538bca
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions Kamek/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,25 @@ namespace Kamek
{
class Program
{
static bool Loud = true;

static void Main(string[] args)
{
Console.WriteLine("Kamek 2.0 by Ninji/Ash Wolf - https://github.com/Treeki/Kamek");
Console.WriteLine();
// Check for the -q/-quiet option first, so we can know if
// we should print the banner line
foreach (var arg in args)
{
if (arg == "-quiet" || arg == "-q")
{
Loud = false;
continue;
}
}

if (Loud) {
Console.WriteLine("Kamek 2.0 by Ninji/Ash Wolf - https://github.com/Treeki/Kamek");
Console.WriteLine();
}

// Parse the command line arguments and do cool things!
var modules = new List<Elf>();
Expand Down Expand Up @@ -63,14 +78,19 @@ static void Main(string[] args)
versions = new VersionInfo(arg.Substring(10));
else if (arg.StartsWith("-select-version="))
selectedVersions.Add(arg.Substring(16));
else if (arg.StartsWith("-valuefile="))
valuefilePath = arg.Substring(11);
else if (arg.StartsWith("-valuefile="))
valuefilePath = arg.Substring(11);
#pragma warning disable 642
else if (arg == "-quiet" || arg == "-q")
; // already handled separately, earlier
#pragma warning restore 642
else
Console.WriteLine("warning: unrecognised argument: {0}", arg);
}
else
{
Console.WriteLine("adding {0} as object..", arg);
if (Loud)
Console.WriteLine("adding {0} as object..", arg);
using (var stream = new FileStream(arg, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
modules.Add(new Elf(stream));
Expand Down Expand Up @@ -129,10 +149,12 @@ static void Main(string[] args)
{
if (selectedVersions.Count > 0 && !selectedVersions.Contains(version.Key))
{
Console.WriteLine("(skipping version {0} as it's not selected)", version.Key);
if (Loud)
Console.WriteLine("(skipping version {0} as it's not selected)", version.Key);
continue;
}
Console.WriteLine("linking version {0}...", version.Key);
if (Loud)
Console.WriteLine("linking version {0}...", version.Key);

var linker = new Linker(version.Value);
foreach (var module in modules)
Expand Down Expand Up @@ -208,6 +230,10 @@ private static void ShowHelp()
Console.WriteLine(" Kamek file1.o [file2.o...] [options]");
Console.WriteLine();
Console.WriteLine("Options:");
Console.WriteLine(" General:");
Console.WriteLine(" -quiet / -q");
Console.WriteLine(" don't print anything to stdout unless there are warnings or errors");
Console.WriteLine();
Console.WriteLine(" Build Mode (select one; defaults to -dynamic):");
Console.WriteLine(" -dynamic");
Console.WriteLine(" generate a dynamically linked Kamek binary for use with the loader");
Expand Down

0 comments on commit c538bca

Please sign in to comment.