mirror of
https://github.com/AdisonCavani/distro-grub-themes.git
synced 2025-06-04 14:32:34 +02:00
Add verbose mode
This commit is contained in:
parent
2029db1737
commit
abf22444f9
4 changed files with 94 additions and 34 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -332,3 +332,4 @@ ASALocalRun/
|
|||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
src/Properties/launchSettings.json
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace DistroGrubThemes
|
|||
{
|
||||
public class ArchiveManager
|
||||
{
|
||||
public static void CreateTarArchive(string sourceDirectory, string outputFile)
|
||||
public static void CreateTarArchive(string sourceDirectory, string outputFile, bool verbose)
|
||||
{
|
||||
Chilkat.Tar tar = new Chilkat.Tar
|
||||
{
|
||||
|
@ -35,9 +35,12 @@ namespace DistroGrubThemes
|
|||
return;
|
||||
}
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.Write("OK\n");
|
||||
Console.ResetColor();
|
||||
if (verbose)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.Write("OK\n");
|
||||
Console.ResetColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
103
src/Program.cs
103
src/Program.cs
|
@ -1,7 +1,6 @@
|
|||
using CommandLine;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
|
@ -19,63 +18,111 @@ namespace DistroGrubThemes
|
|||
static void RunOptions(ProgramOptions opts)
|
||||
{
|
||||
Program program = new Program();
|
||||
|
||||
string path = program.CheckRepoPath(opts.RepositoryPath);
|
||||
|
||||
program.UpdateAssets(path);
|
||||
Console.WriteLine();
|
||||
program.UpdateArchive(path);
|
||||
if (opts.UpdateFonts)
|
||||
{
|
||||
program.UpdateFonts(path + @"\font", path + @"\customize", opts.VerboseMode);
|
||||
}
|
||||
|
||||
if (opts.UpdateIcons)
|
||||
{
|
||||
if (opts.VerboseMode)
|
||||
Console.WriteLine();
|
||||
|
||||
program.UpdateIcons(path + @"\assets\icons", path + @"\customize", opts.VerboseMode);
|
||||
}
|
||||
|
||||
if (opts.UpdateArchives)
|
||||
{
|
||||
if (opts.VerboseMode)
|
||||
Console.WriteLine();
|
||||
|
||||
program.UpdateArchive(path, opts.VerboseMode);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateArchive(string path)
|
||||
void UpdateArchive(string path, bool verbose)
|
||||
{
|
||||
if (!verbose)
|
||||
Console.Write("Creating .tar archives ... ");
|
||||
|
||||
foreach (var directory in DirectoriesDictionary(path + @"\customize", path))
|
||||
{
|
||||
Console.Write("Creating " + directory.Value + ".tar archive ... ");
|
||||
ArchiveManager.CreateTarArchive(directory.Key, path + @"\themes\" + directory.Value + ".tar");
|
||||
if (verbose)
|
||||
Console.Write("Creating " + directory.Value + ".tar archive ... ");
|
||||
|
||||
ArchiveManager.CreateTarArchive(directory.Key, path + @"\themes\" + directory.Value + ".tar", verbose);
|
||||
}
|
||||
|
||||
if (!verbose)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.Write("OK\n");
|
||||
Console.ResetColor();
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateAssets(string path)
|
||||
void UpdateIcons(string iconsPath, string customizePath, bool verbose)
|
||||
{
|
||||
UpdateIcons(path + @"\assets\icons", path + @"\customize");
|
||||
UpdateFonts(path + @"\font", path + @"\customize");
|
||||
}
|
||||
|
||||
void UpdateIcons(string iconsPath, string customizePath)
|
||||
{
|
||||
Console.Write("\nUpdating icons ... ");
|
||||
var icons = FilesArray(iconsPath);
|
||||
if (!verbose)
|
||||
Console.Write("Copying icons ... ");
|
||||
|
||||
foreach (var directory in DirectoriesArray(customizePath))
|
||||
{
|
||||
foreach (var icon in icons)
|
||||
foreach (var icon in FilesArray(iconsPath))
|
||||
{
|
||||
if (verbose)
|
||||
Console.Write("Copying " + icon + " ... ");
|
||||
|
||||
File.Copy(iconsPath + @"\" + icon, directory + @"\icons\" + icon, true);
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.Write("OK\n");
|
||||
Console.ResetColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.Write("OK\n");
|
||||
Console.ResetColor();
|
||||
if (!verbose)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.Write("OK\n");
|
||||
Console.ResetColor();
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateFonts(string fontsPath, string customizePath)
|
||||
void UpdateFonts(string fontsPath, string customizePath, bool verbose)
|
||||
{
|
||||
Console.Write("Updating fonts ... ");
|
||||
var fonts = FilesArray(fontsPath);
|
||||
if (!verbose)
|
||||
Console.Write("Copying fonts ... ");
|
||||
|
||||
foreach (var directory in DirectoriesArray(customizePath))
|
||||
{
|
||||
foreach (var font in fonts)
|
||||
foreach (var font in FilesArray(fontsPath))
|
||||
{
|
||||
if (verbose)
|
||||
Console.Write("Copying " + font + " ... ");
|
||||
|
||||
File.Copy(fontsPath + @"\" + font, directory + @"\" + font, true);
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.Write("OK\n");
|
||||
Console.ResetColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.Write("OK\n");
|
||||
Console.ResetColor();
|
||||
if (!verbose)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.Write("OK\n");
|
||||
Console.ResetColor();
|
||||
}
|
||||
}
|
||||
|
||||
List<string> FilesArray(string folderPath)
|
||||
|
|
|
@ -7,7 +7,16 @@ namespace DistroGrubThemes
|
|||
[Option('r', "repository", Required = true, HelpText = "Path to repository.")]
|
||||
public string RepositoryPath { get; set; }
|
||||
|
||||
[Option('a', "archive", HelpText = "Create theme archive.")]
|
||||
public string ArchivedFiles { get; set; }
|
||||
[Option('a', "archive", HelpText = "Update archives.")]
|
||||
public bool UpdateArchives { get; set; }
|
||||
|
||||
[Option('f', "fonts", HelpText = "Update fonts.")]
|
||||
public bool UpdateFonts { get; set; }
|
||||
|
||||
[Option('i', "icons", HelpText = "Update icons.")]
|
||||
public bool UpdateIcons { get; set; }
|
||||
|
||||
[Option('v', "verbose" , HelpText = "Enable debug messages.")]
|
||||
public bool VerboseMode { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue