Exemple #1
0
        static void Main(string[] args)
        {
            ReadLine.AutoCompletionHandler = new AutoCompletionHandler();
            var apiKey = Environment.GetEnvironmentVariable(ApiKeyPath);

            if (string.IsNullOrEmpty(apiKey))
            {
                apiKey = ReadLine.Read("Redmine API key is not set yet, please input it and press enter: ");
                Environment.SetEnvironmentVariable(ApiKeyPath, apiKey);
            }
            var baseUri = Environment.GetEnvironmentVariable(BaseUriPath);

            if (string.IsNullOrEmpty(baseUri))
            {
                baseUri = ReadLine.Read("Redmine base uri is not set yet, please input it and press enter: ");
                Environment.SetEnvironmentVariable(BaseUriPath, baseUri);
            }
            var projectIdString = Environment.GetEnvironmentVariable(ProjectIdPath);

            if (string.IsNullOrEmpty(projectIdString))
            {
                projectIdString = ReadLine.Read("Redmine project id is not set yet, please input it and press enter: ");
                Environment.SetEnvironmentVariable(ProjectIdPath, projectIdString);
            }
            var projectId = int.Parse(projectIdString);

            var apiClient = RestService.For <IRedmineApiClient>(new HttpClient(new RedmineHttpClientHandler(apiKey))
            {
                BaseAddress = new Uri(baseUri)
            });

            var projectCache = new RedmineProjectCache(apiClient, projectId);

            projectCache.InitializeAsync().Wait();
            Console.WriteLine("Redmine project cache initializing...");

            if (args.Length == 0)
            {
                string command = null;
                do
                {
                    command = ReadLine.Read();
                    args    = command.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                } while(command != "q");
            }
            Console.ReadLine();
        }
Exemple #2
0
        public void StartInteractiveShell()
        {
            while (_continueLoop)
            {
                string input = ReadLine.Read(Prompt);

                ICommandAction command;
                if (_interpreter.TryParseCommand(input, out command))
                {
                    if (command.TryExecute(null, _listeners))
                    {
                        ReadLine.AddHistory(input);
                    }
                }
                else
                {
                    Console.WriteLine("Unrecognized command");
                }
            }
        }
Exemple #3
0
 public virtual string ReadLine()
 {
     return(In == null?RL.Read() : In.ReadLine());
 }
Exemple #4
0
 public static Task <string> ReadAsync(string prompt, CancellationToken cancellationToken)
 {
     return(Task.Run(() => ReadLine.Read(prompt, cancellationToken: cancellationToken)));
 }