43 lines
1.0 KiB
C
43 lines
1.0 KiB
C
#include <stdio.h>
|
|
#include <string.h>
|
|
#include "config.h"
|
|
|
|
void version() {
|
|
printf("Ninja Virtual Machine version %i (compiled %s, %s)\n", PROJECT_VERSION, __DATE__, __TIME__);
|
|
}
|
|
|
|
void help() {
|
|
printf("usage: ./njvm [option] [option] ...\n\t--version\tshow version and exit\n\t--help\t\tshow this help and exit");
|
|
}
|
|
void printArgs(int argc, char *argv[]){
|
|
for (int i = 0; i < argc; ++i) {
|
|
printf("%s\n", argv[i]);
|
|
}
|
|
}
|
|
void useption(int argc, char *argv[]){
|
|
if (argc > 1) {
|
|
if (strcmp(argv[1], "--version") == 0) {
|
|
version();
|
|
} else if (strcmp(argv[1], "--help") == 0) {
|
|
help();
|
|
} else if (argc != 0) {
|
|
printf("unknown command line argument '%s', try './njvm --help'", argv[1]);
|
|
}
|
|
}
|
|
}
|
|
|
|
int main(int argc, char *argv[]) {
|
|
printArgs(argc,argv);
|
|
if (argc > 1) useption(argc,argv);
|
|
else {
|
|
|
|
// Started
|
|
printf("Ninja Virtual Machine started\n");
|
|
|
|
|
|
|
|
// Stopped
|
|
printf("Ninja Virtual Machine stopped\n");
|
|
return 0;
|
|
}
|
|
} |