Beispiel #1
0
        static async Task <int> MainAsync(string [] args)
        {
            // set up the very basic global services/environment
            var clientApp = new ConsoleClientApp();

            clientApp.Initialize(
                logProvider: new LogProvider(LogLevel.Info, null));

            if (args.Length > 0)
            {
                await WorkbookPlayerMain(args [0]);
            }
            else
            {
                await ReplPlayerMain();
            }

            // Nevermind this... it'll get fixed!
            await Task.Delay(Timeout.Infinite);

            return(0);
        }
Beispiel #2
0
        static async Task <int> MainAsync(string [] args)
        {
            ClientSessionUri sessionUri = null;
            TextWriter       logWriter  = null;
            var showHelp = false;

            var options = new OptionSet {
                { "usage: xic [OPTIONS]+ [URI]" },
                { "" },
                { "Options:" },
                { "" },
                { "l|log=", "Write debugging log to file",
                  v => logWriter = new StreamWriter(v) },
                { "h|help", "Show this help",
                  v => showHelp = true }
            };

            try {
                args = options.Parse(args).ToArray();
            } catch (Exception e) {
                Error.WriteLine($"Invalid option: {e.Message}");
                showHelp = true;
            }

            if (showHelp)
            {
                options.WriteOptionDescriptions(Out);
                return(1);
            }

            if (args.Length > 0)
            {
                if (!ClientSessionUri.TryParse(args [0], out sessionUri))
                {
                    Error.WriteLine($"Invalid URI: {args [0]}");
                    return(1);
                }
            }

            // set up the very basic global services/environment
            var clientApp = new ConsoleClientApp();

            clientApp.Initialize(
                logProvider: new LogProvider(LogLevel.Info, logWriter));

            // Now create and get ready to deal with the session; a more complete
            // client should handle more than just OnNext from the observer.
            var session = new InteractiveSession(agentUri: sessionUri);

            session.Events.Subscribe(new Observer <InteractiveSessionEvent> (OnSessionEvent));

            if (sessionUri?.WorkbookPath != null)
            {
                await WorkbookPlayerMain(session, sessionUri);
            }
            else
            {
                await ReplPlayerMain(session);
            }

            // Nevermind this... it'll get fixed!
            await Task.Delay(Timeout.Infinite);

            return(0);
        }