static public CLIManager CreateManager(CLIContext context) { var manager = new CLIManager(context); if (context.Settings.IsMockSystemCtl) { var mockSystemCtl = new MockSystemCtlHelper(context); manager.PostInstall.ArduinoPlugAndPlay.Verifier.SystemCtl = mockSystemCtl; manager.PostInstall.Docker.Verifier.SystemCtl = mockSystemCtl; manager.PostInstall.Supervisor.Verifier.SystemCtl = mockSystemCtl; manager.PostInstall.WWW.Verifier.SystemCtl = mockSystemCtl; manager.PostInstall.Mqtt.SystemCtl = mockSystemCtl; manager.PostInstall.Verifier.SystemCtl = mockSystemCtl; manager.PostInstall.Verifier.ArduinoPlugAndPlay.SystemCtl = mockSystemCtl; manager.PostInstall.Verifier.Docker.SystemCtl = mockSystemCtl; manager.PostInstall.Verifier.Supervisor.SystemCtl = mockSystemCtl; manager.PostInstall.Verifier.WWW.SystemCtl = mockSystemCtl; } if (context.Settings.IsMockDocker) { var mockDocker = new MockDockerHelper(context); manager.PostInstall.Mqtt.Docker = mockDocker; manager.PostInstall.Mqtt.Verifier.Docker = mockDocker; manager.PostInstall.Verifier.Mosquitto.Docker = mockDocker; } return(manager); }
public CLIManager(CLIContext context) { Console.WriteLine(" Working directory: " + context.IndexDirectory); Context = context; Starter = new ProcessStarter(); Starter.WorkingDirectory = Context.IndexDirectory; PostInstall = new Installers.PostInstaller(context); Devices = new DeviceManager(context); MqttBridge = new MqttBridgeStarter(context); Verifier = new Verifier(context); }
public PostInstaller(CLIContext context) { Context = context; Prepare = new Installers.PostInstaller(context); }
public PathHelper(CLIContext context) { Context = context; }
public DockerHelper(CLIContext context) { Context = context; Starter = new ProcessStarter(context.IndexDirectory); }
public static void Main(string[] args) { Console.WriteLine("===== GrowSense CLI Console ====="); var arguments = new Arguments(args); var workingDirectory = Path.GetFullPath("/"); if (arguments.Contains("dir")) { workingDirectory = Path.GetFullPath(arguments["dir"]); } var settings = GetSettings(workingDirectory, arguments); var context = new CLIContext(workingDirectory, settings); var manager = CreateManager(context); try { if (arguments.KeylessArguments.Length > 0) { var command = arguments.KeylessArguments[0]; Console.WriteLine(" Command: " + command); switch (command) { case "post-install": //Console.WriteLine("Post install"); manager.PostInstallActions(); break; case "stop": //Console.WriteLine("Stop"); manager.Stop(); break; case "start": //Console.WriteLine("Stop"); manager.Start(); break; case "verify": //Console.WriteLine("Verify"); manager.Verify(); break; case "config": //Console.WriteLine("Config"); var verify = true; if (arguments.Contains("verify")) { verify = Convert.ToBoolean(arguments["verify"]); } manager.ApplySettings(verify); break; case "add-device": var port = arguments["port"]; manager.AddDevice(port); break; case "start-mqtt-bridge": var deviceName = arguments["name"]; manager.StartMqttBridge(deviceName); break; default: Console.WriteLine("Unknown command: " + command); break; } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); Environment.Exit(1); } }
public DeviceManager(CLIContext context) { Context = context; Starter = new ProcessStarter(context.IndexDirectory); }