Allow CWD to be passed by command line arg

This commit is contained in:
zontreck 2024-05-25 05:03:58 -07:00
parent e14f788684
commit aac70e86ee

View file

@ -6,14 +6,22 @@ import 'package:servermanager/game.dart';
import 'package:servermanager/packets/ClientPackets.dart'; import 'package:servermanager/packets/ClientPackets.dart';
import 'package:servermanager/structs/settings.dart'; import 'package:servermanager/structs/settings.dart';
void main() async { void main(List<String> args) async {
print("Current working directory: ${Directory.current.path}");
print("/!\\ This server is now starting... /!\\\n\n");
print("Checking for command line args...");
if (args.isNotEmpty) {
print("Changing current working directory to ${args[0]}");
Directory.current = args[0];
}
ClientPackets.register(); ClientPackets.register();
// Set up paths // Set up paths
Settings settings = Settings(); Settings settings = Settings();
await settings.Read(); await settings.Read();
print( //print(
"Server Admin Credentials\nUsername: ${settings.serverLoginCreds.username}\nPassword: ${settings.serverLoginCreds.password}"); // "Server Admin Credentials\nUsername: ${settings.serverLoginCreds.username}\nPassword: ${settings.serverLoginCreds.password}");
PathHelper helper = PathHelper(pth: Directory.current.path); PathHelper helper = PathHelper(pth: Directory.current.path);
helper = helper.resolve("data").mkdir(); helper = helper.resolve("data").mkdir();