Added basic command-line arguments parsing

This commit is contained in:
Tristan B. Velloza Kildaire 2021-03-02 21:51:49 +02:00
parent 505764b8bb
commit 639455d792
3 changed files with 48 additions and 4 deletions

View File

@ -9,8 +9,13 @@
module tlang;
import std.stdio;
import commandline.args;
void main()
void main(string[] args)
{
/* TODO: Replace with something else */
writeln("tlang NO_PUBLISH_RELEASE");
/* Parse the command-line arguments */
parseCommandLine(args);
}

View File

@ -2,7 +2,11 @@ module commandline.args;
import jcli;
void parseCommandLine(string[] args)
void parseCommandLine(string[] arguments)
{
/* TODO: Parse command-line options here */
/* Create an instance of the JCLI command-line parser */
CommandLineInterface!(commandline.commands) commandLineSystem = new CommandLineInterface!(commandline.commands)();
/* Parse the command-line arguments */
commandLineSystem.parseAndExecute(arguments);
}

View File

@ -0,0 +1,35 @@
/**
* Commands
*
* All command-line arguments and their impementations
*/
module commandline.commands;
import jcli;
import std.stdio;
@Command("help", "Shows the help screen")
struct helpCommand
{
void onExecute()
{
}
}
@Command("compile", "Compiles the given file(s)")
struct compileCommand
{
@CommandPositionalArg(0, "source file", "The source file to compile")
string sourceFile;
// @CommandRawListArg
// string[] d;
// TODO: Get array
void onExecute()
{
writeln("Compiling source file: "~sourceFile);
}
}