Example #1
0
 public ConsoleCurriculumExporter()
 {
     _fluentConsole = new FluentConsole()
                      .Encoding(Encoding.UTF8)
                      .TextColor(ConsoleColor.Black)
                      .BackgroundColor(ConsoleColor.White)
                      .Size(110, 44);
 }
Example #2
0
    /// <summary>
    /// Prompts the user to answer a yes or no question.
    /// </summary>
    /// <param name="type">The log type of the message.</param>
    /// <param name="options">Log options to override default logging behavior.</param>
    public bool Run(LogType type, LogOptions options)
    {
        var console = new FluentConsole();

        options             = options ?? new LogOptions();
        options.IsEndOfLine = false;
        ConsoleKey response;

        do
        {
            console.Log(_question, type, options);
            response = console.ReadKey(false).Key;
            console.WriteLine();
        } while (!_allowedResponses.ContainsKey(response));
        return(_allowedResponses[response]);
    }
Example #3
0
        private static void Main(Arguments args)
        {
            if (args.BackgroundConnectionCount < 0)
            {
                throw new ArgumentValidationException("Parallel count cannot be negative.");
            }

            if (args.BackgroundConnectionCount < 1)
            {
                throw new NotSupportedException("Current implementaton requires at least one background connection (this might be improved in the future).");
            }

            if (args.Verbose)
            {
                FtpTrace.AddListener(new ConsoleTraceListener());
            }

            var ftpUrl   = new Uri(args.FtpUrl);
            var password = Environment.GetEnvironmentVariable(args.FtpPasswordVariableName, EnvironmentVariableTarget.Process);

            if (string.IsNullOrEmpty(password))
            {
                throw new ArgumentValidationException($"Password env variable '{args.FtpPasswordVariableName}' is not set for the current process (user/machine vars are ignored).");
            }

            FluentConsole.White.Line(ftpUrl);
            var started = DateTime.Now;

            var basePath    = ftpUrl.LocalPath;
            var credentials = new NetworkCredential(args.FtpUserName, password);
            var sourceInfo  = Directory.Exists(args.SourcePath) ? (FileSystemInfo) new DirectoryInfo(args.SourcePath) : new FileInfo(args.SourcePath);

            using (var mainClient = CreateFtpClient(ftpUrl, credentials, args.FtpUseActive, retry: args.InterimFtpRetryLogin))
                using (var backgroundPool = new FtpClientPool(() => CreateFtpClient(ftpUrl, credentials, args.FtpUseActive, retry: true), args.BackgroundConnectionCount))
                    using (var process = new Process(mainClient, backgroundPool, args.Excludes.AsReadOnlyList())) {
                        process.SynchronizeTopLevel(sourceInfo, basePath);
                    }

            FluentConsole.NewLine().Green.Line(@"Finished in {0:dd\.hh\:mm\:ss}.", DateTime.Now - started);
        }
Example #4
0
    /// <summary>
    /// Displays the menu, prompts the user for a response, and returns the response.
    /// </summary>
    /// <param name="type">The log type of the menu.</param>
    /// <param name="options">Log options to override default logging behavior.</param>
    public char Run(LogType type, LogOptions options)
    {
        var console = new FluentConsole();

        options             = options ?? new LogOptions();
        options.IsEndOfLine = true;

        console.LogSeparator(type, options);
        if (!string.IsNullOrWhiteSpace(_title))
        {
            console.Log($" {_title}", type, options).LogSeparator(type, options);
        }
        if (!string.IsNullOrWhiteSpace(_detail))
        {
            console.Log(_detail, type, options).WriteLine();
        }
        foreach (KeyValuePair <char, string> option in _options)
        {
            console.Log($"  {option.Key} - {option.Value}", type, options);
        }
        console.LogSeparator(type, options).WriteLine();

        var left = console.CursorLeft;
        var top  = console.CursorTop;

        options.IsEndOfLine = false;
        var response = char.MinValue;

        do
        {
            console.SetCursorPosition(left, top).Log("Make your selection:  \b", type, options);
            response = console.ReadKey().KeyChar;
        } while (!_options.ContainsKey(response));
        console.WriteLine();

        return(response);
    }
Example #5
0
 public static FluentConsole SetEncoding(this FluentConsole logger, Encoding encoding)
 {
     logger.OutputEncoding = encoding;
     return(logger);
 }
Example #6
0
        private void Log(int depth, ItemAction state, string itemName, string message = null)
        {
            var line = $"{new string(' ', depth*2)}{state.DisplayPrefix}{itemName}{(message != null ? ": " + message : "")}";

            FluentConsole.Color(state.Color).Line(line);
        }