using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spectre.Console;

namespace RedundancyFinderCLI
{
    public static class Global
    {

        public static void WriteLine(string v)
        {
            AnsiConsole.MarkupLine(Format(v));
        }

        public static string Format(string v)
        {
            string now = Markup.Escape($"[{DateTime.Now.ToString("HH:mm:ss")}]");
            return $"[gray]{now}[/] {v}";
        }

        public static string GetSizeFormat(ulong totalSize)
        {
            string sizeUnit = "B";
            double size = totalSize;
            while (size > 1024)
            {
                size /= 1024d;
                sizeUnit = sizeUnit switch
                {
                    "B" => "KB",
                    "KB" => "MB",
                    "MB" => "GB",
                    "GB" => "TB",
                    _ => sizeUnit
                };

            }
            string sizeFormat = $"{size:.00} {sizeUnit}";
            return sizeFormat;
        }
    }
}
