Ejemplo n.º 1
0
        public void GivenArgValues_WhenRegisteredAtRuntime_ThenAppRunsWithGivenValues()
        {
            var validArgs = new string[]
            {
                "/baz:baz",
                "-foo=foo",
                "--bar~bar"
            };

            var _cliHandler   = new CliHandler();
            var _argRegistrar = new CliArgRegistrar <FakeCliArgKey>();

            var expected = new Dictionary <FakeCliArgKey, string>();

            expected.Add(FakeCliArgKey.FOO, "foo");
            expected.Add(FakeCliArgKey.BAR, "bar");
            expected.Add(FakeCliArgKey.BAZ, "baz");

            var actual = _cliHandler.GetCliArgRegistrar <FakeCliArgKey>(validArgs).Registry;

            Assert.AreEqual(expected.Count, actual.Count);
            Assert.AreEqual(expected[FakeCliArgKey.FOO], actual[FakeCliArgKey.FOO]);
            Assert.AreEqual(expected[FakeCliArgKey.BAR], actual[FakeCliArgKey.BAR]);
            Assert.AreEqual(expected[FakeCliArgKey.BAZ], actual[FakeCliArgKey.BAZ]);
        }
Ejemplo n.º 2
0
 public CliOption(string name, string alias, string description, CliHandler handler, CliHandling cliHandling = CliHandling.Switch)
 {
     Name        = name;
     Alias       = alias;
     Description = description;
     Handler     = handler;
     Handling    = cliHandling;
 }
Ejemplo n.º 3
0
        private static void Main(string[] args)
        {
            var customCulture = (CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();

            customCulture.NumberFormat.NumberDecimalSeparator    = ".";
            System.Threading.Thread.CurrentThread.CurrentCulture = customCulture;
            Console.WriteLine("Welcome to mutateful!");
            Console.WriteLine("Open Ableton Live, drop mutateful-connector.amxd onto one of the tracks, and start entering formulas.");
            CliHandler.Start();
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
Ejemplo n.º 4
0
        public void GivenNoArgValues_WhenRegisteredAtRuntime_ThenAppRunsWithDefaultValues()
        {
            var noArgs = new string[] { string.Empty };

            var _cliHandler   = new CliHandler();
            var _argRegistrar = new CliArgRegistrar <FakeCliArgKey>();

            var expected = new Dictionary <FakeCliArgKey, string>();

            expected.Add(FakeCliArgKey.FOO, string.Empty);
            expected.Add(FakeCliArgKey.BAR, string.Empty);
            expected.Add(FakeCliArgKey.BAZ, string.Empty);

            var actual = _cliHandler.GetCliArgRegistrar <FakeCliArgKey>(noArgs).Registry;

            Assert.AreEqual(expected.Count, actual.Count);
            Assert.AreEqual(expected[FakeCliArgKey.FOO], actual[FakeCliArgKey.FOO]);
            Assert.AreEqual(expected[FakeCliArgKey.BAR], actual[FakeCliArgKey.BAR]);
            Assert.AreEqual(expected[FakeCliArgKey.BAZ], actual[FakeCliArgKey.BAZ]);
        }
Ejemplo n.º 5
0
        public static async Task ProcessUdpDataAsync(UdpClient udpClient, ChannelWriter <InternalCommand> writer)
        {
            await foreach (byte[] data in ReceiveUdpDataAsync(udpClient).ConfigureAwait(false))
            {
                if (Decoder.IsTypedCommand(data))
                {
                    // new logic for handling input
                    switch (Decoder.GetCommandType(data[3]))
                    {
                    case InternalCommandType.OutputString:
                        string text = Decoder.GetText(data);
                        Console.WriteLine(text);
                        break;

                    case InternalCommandType.SetClipSlot:
                        break;

                    case InternalCommandType.SetAndEvaluateClipSlot:
                        break;

                    case InternalCommandType.EvaluateClipSlots:
                        break;

                    case InternalCommandType.UnknownCommand:
                        break;
                    }
                }
                else // old logic
                {
                    var result = CliHandler.HandleInput(data);
                    if (result != ClipSlot.Empty)
                    {
                        await writer.WriteAsync(new InternalCommand(InternalCommandType.SetClipSlot, result, new[] { result.Clip.ClipReference }));
                    }
                }
            }
        }
Ejemplo n.º 6
0
 static void Main(string[] args)
 {
     CliHandler.HandleCli(args);
 }