Added basic command-line arguments parsing
This commit is contained in:
parent
505764b8bb
commit
639455d792
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue