+ for (int i = 2; i < args.length; i++)
+ manager.load_unit(args[i]);
+
+ } else if (args[1] == "cancel") {
+
+ if (args.length < 3) {
+ stderr.printf("Missing argument.\n");
+ return 1;
+ }
+
+ for (int i = 2; i < args.length; i++) {
+ uint32 id;
+
+ if (args[i].scanf("%u", out id) != 1) {
+ stderr.printf("Failed to parse argument.\n");
+ return 1;
+ }
+
+ ObjectPath p = manager.get_job(id);
+
+ Job j = bus.get_object (
+ "org.freedesktop.systemd1",
+ p,
+ "org.freedesktop.systemd1.Job") as Job;
+
+ j.cancel();
+ }
+
+ } else if (args[1] == "start" ||
+ args[1] == "stop" ||
+ args[1] == "reload" ||
+ args[1] == "restart") {
+
+ if (args.length < 3) {
+ stderr.printf("Missing argument.\n");
+ return 1;
+ }
+
+ for (int i = 2; i < args.length; i++) {
+
+ ObjectPath p = manager.load_unit(args[i]);
+
+ Unit u = bus.get_object(
+ "org.freedesktop.systemd1",
+ p,
+ "org.freedesktop.systemd1.Unit") as Unit;
+
+ string mode = replace ? "replace" : "fail";
+
+ if (args[1] == "start")
+ u.start(mode);
+ else if (args[1] == "stop")
+ u.stop(mode);
+ else if (args[1] == "restart")
+ u.restart(mode);
+ else if (args[1] == "reload")
+ u.reload(mode);
+ }
+
+ } else if (args[1] == "isolate") {
+
+ if (args.length != 3) {
+ stderr.printf("Missing argument.\n");
+ return 1;
+ }
+
+ ObjectPath p = manager.load_unit(args[2]);
+
+ Unit u = bus.get_object(
+ "org.freedesktop.systemd1",
+ p,
+ "org.freedesktop.systemd1.Unit") as Unit;
+
+ u.start("isolate");
+
+ } else if (args[1] == "monitor") {
+
+ manager.subscribe();
+
+ manager.unit_new += on_unit_new;
+ manager.unit_removed += on_unit_removed;
+ manager.job_new += on_job_new;
+ manager.job_removed += on_job_removed;
+
+ MainLoop l = new MainLoop();
+ l.run();
+
+ } else if (args[1] == "dump")
+ stdout.puts(manager.dump());
+
+ else if (args[1] == "snapshot") {
+
+ ObjectPath p = manager.create_snapshot(args.length > 2 ? args[2] : "");
+
+ Unit u = bus.get_object(
+ "org.freedesktop.systemd1",
+ p,
+ "org.freedesktop.systemd1.Unit") as Unit;
+
+ stdout.printf("%s\n", u.id);
+
+ } else if (args[1] == "daemon-reload")
+ manager.reload();
+
+ else if (args[1] == "daemon-reexecute" || args[1] == "daemon-reexec")
+ manager.reexecute();
+
+ else if (args[1] == "daemon-exit")
+ manager.exit();
+
+ else if (args[1] == "show-environment") {
+ foreach(var x in manager.environment)
+ stderr.printf("%s\n", x);
+
+ } else if (args[1] == "set-environment")
+ manager.set_environment(args[2:args.length]);
+
+ else if (args[1] == "unset-environment")
+ manager.unset_environment(args[2:args.length]);
+
+ else {