mirror of
https://github.com/AdisonCavani/distro-grub-themes.git
synced 2025-06-06 07:12:33 +02:00
Move old C# program to legacy branch
This commit is contained in:
parent
60c69444a5
commit
8fecea3e02
7 changed files with 0 additions and 310 deletions
|
@ -1,53 +0,0 @@
|
||||||
using ICSharpCode.SharpZipLib.Tar;
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace DistroGrubThemes;
|
|
||||||
|
|
||||||
public static class ArchiveManager
|
|
||||||
{
|
|
||||||
public static void CreateTarArchive(string sourceDirectory, string outputFile, bool verbose)
|
|
||||||
{
|
|
||||||
Stream outStream = File.Create(outputFile);
|
|
||||||
TarArchive tarArchive = TarArchive.CreateOutputTarArchive(outStream);
|
|
||||||
|
|
||||||
// Case sensitive
|
|
||||||
tarArchive.RootPath = sourceDirectory.Replace('\\', '/');
|
|
||||||
if (tarArchive.RootPath.EndsWith("/"))
|
|
||||||
tarArchive.RootPath = tarArchive.RootPath.Remove(tarArchive.RootPath.Length - 1);
|
|
||||||
|
|
||||||
AddDirectoryFilesToTar(tarArchive, sourceDirectory, true);
|
|
||||||
tarArchive.Close();
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
Console.ForegroundColor = ConsoleColor.Green;
|
|
||||||
Console.Write("OK\n");
|
|
||||||
Console.ResetColor();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Example: https://github.com/icsharpcode/SharpZipLib/wiki/GZip-and-Tar-Samples
|
|
||||||
private static void AddDirectoryFilesToTar(TarArchive tarArchive, string sourceDirectory, bool recurse)
|
|
||||||
{
|
|
||||||
// Optionally, write an entry for the directory itself.
|
|
||||||
// Specify false for recursion here if we will add the directory's files individually.
|
|
||||||
TarEntry tarEntry = TarEntry.CreateEntryFromFile(sourceDirectory);
|
|
||||||
tarArchive.WriteEntry(tarEntry, false);
|
|
||||||
|
|
||||||
// Write each file to the tar.
|
|
||||||
string[] filenames = Directory.GetFiles(sourceDirectory);
|
|
||||||
foreach (string filename in filenames)
|
|
||||||
{
|
|
||||||
tarEntry = TarEntry.CreateEntryFromFile(filename);
|
|
||||||
tarArchive.WriteEntry(tarEntry, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (recurse)
|
|
||||||
{
|
|
||||||
string[] directories = Directory.GetDirectories(sourceDirectory);
|
|
||||||
foreach (string directory in directories)
|
|
||||||
AddDirectoryFilesToTar(tarArchive, directory, recurse);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
|
||||||
<Authors>Adison Cavani</Authors>
|
|
||||||
<Company>Adison Cavani</Company>
|
|
||||||
<LangVersion>10</LangVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="CommandLineParser" Version="2.8.0" />
|
|
||||||
<PackageReference Include="SharpZipLib" Version="1.3.3" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
|
@ -1,25 +0,0 @@
|
||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio Version 17
|
|
||||||
VisualStudioVersion = 17.0.31717.71
|
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DistroGrubThemes", "DistroGrubThemes.csproj", "{0CCFA519-E529-4AF9-B800-92FC96351EE9}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|Any CPU = Debug|Any CPU
|
|
||||||
Release|Any CPU = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{0CCFA519-E529-4AF9-B800-92FC96351EE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{0CCFA519-E529-4AF9-B800-92FC96351EE9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{0CCFA519-E529-4AF9-B800-92FC96351EE9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{0CCFA519-E529-4AF9-B800-92FC96351EE9}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
|
||||||
SolutionGuid = {C18C7214-AE56-46A5-8C62-8A5A2B8886D7}
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
28
src/Help.cs
28
src/Help.cs
|
@ -1,28 +0,0 @@
|
||||||
using CommandLine;
|
|
||||||
using CommandLine.Text;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace DistroGrubThemes
|
|
||||||
{
|
|
||||||
public class Help
|
|
||||||
{
|
|
||||||
public static void DisplayHelp<T>(ParserResult<T> result, IEnumerable<Error> errs)
|
|
||||||
{
|
|
||||||
HelpText helpText = null;
|
|
||||||
if (errs.IsVersion())
|
|
||||||
helpText = HelpText.AutoBuild(result);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
helpText = HelpText.AutoBuild(result, h =>
|
|
||||||
{
|
|
||||||
h.AdditionalNewLineAfterOption = false;
|
|
||||||
h.Heading = string.Empty;
|
|
||||||
h.Copyright = string.Empty;
|
|
||||||
return HelpText.DefaultParsingErrorsHandler(result, h);
|
|
||||||
}, e => e);
|
|
||||||
}
|
|
||||||
Console.WriteLine(helpText);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
161
src/Program.cs
161
src/Program.cs
|
@ -1,161 +0,0 @@
|
||||||
using CommandLine;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace DistroGrubThemes;
|
|
||||||
|
|
||||||
internal class Program
|
|
||||||
{
|
|
||||||
static void Main(string[] args)
|
|
||||||
{
|
|
||||||
var parser = new Parser(with => with.HelpWriter = null);
|
|
||||||
var parserResult = parser.ParseArguments<ProgramOptions>(args);
|
|
||||||
parserResult.WithParsed(options => RunOptions(options)).WithNotParsed(errs => Help.DisplayHelp(parserResult, errs));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void RunOptions(ProgramOptions opts)
|
|
||||||
{
|
|
||||||
Program program = new();
|
|
||||||
string path = program.CheckRepoPath(opts.RepositoryPath);
|
|
||||||
|
|
||||||
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, bool verbose)
|
|
||||||
{
|
|
||||||
if (!verbose)
|
|
||||||
Console.Write("Creating .tar archives ... ");
|
|
||||||
|
|
||||||
foreach (var directory in DirectoriesDictionary($"{path}\\customize", path))
|
|
||||||
{
|
|
||||||
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 UpdateIcons(string iconsPath, string customizePath, bool verbose)
|
|
||||||
{
|
|
||||||
if (!verbose)
|
|
||||||
Console.Write("Copying icons ... ");
|
|
||||||
|
|
||||||
foreach (var directory in DirectoriesArray(customizePath))
|
|
||||||
{
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!verbose)
|
|
||||||
{
|
|
||||||
Console.ForegroundColor = ConsoleColor.Green;
|
|
||||||
Console.Write("OK\n");
|
|
||||||
Console.ResetColor();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdateFonts(string fontsPath, string customizePath, bool verbose)
|
|
||||||
{
|
|
||||||
if (!verbose)
|
|
||||||
Console.Write("Copying fonts ... ");
|
|
||||||
|
|
||||||
foreach (var directory in DirectoriesArray(customizePath))
|
|
||||||
{
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!verbose)
|
|
||||||
{
|
|
||||||
Console.ForegroundColor = ConsoleColor.Green;
|
|
||||||
Console.Write("OK\n");
|
|
||||||
Console.ResetColor();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<string> FilesArray(string folderPath)
|
|
||||||
{
|
|
||||||
return new List<string>(Directory.GetFiles(folderPath).Select(Path.GetFileName));
|
|
||||||
}
|
|
||||||
|
|
||||||
string[] DirectoriesArray(string directoryPath)
|
|
||||||
{
|
|
||||||
return Directory.GetDirectories(directoryPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
Dictionary<string, string> DirectoriesDictionary(string directoryPath, string repoPath)
|
|
||||||
{
|
|
||||||
var dirsArray = Directory.GetDirectories(directoryPath);
|
|
||||||
|
|
||||||
return dirsArray.ToDictionary(key => key, value => value[(value.IndexOf(@"customize\") + 10)..]);
|
|
||||||
}
|
|
||||||
|
|
||||||
string CheckRepoPath(string path)
|
|
||||||
{
|
|
||||||
if (Directory.Exists(path) && path.Contains("distro-grub-themes"))
|
|
||||||
{
|
|
||||||
int index = path.IndexOf("distro-grub-themes") + 18;
|
|
||||||
return path[..index];
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.ForegroundColor = ConsoleColor.Red;
|
|
||||||
Console.Write("error: ");
|
|
||||||
Console.ResetColor();
|
|
||||||
Console.Write("could not find repository in this path");
|
|
||||||
Environment.Exit(1);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
using CommandLine;
|
|
||||||
|
|
||||||
namespace DistroGrubThemes
|
|
||||||
{
|
|
||||||
public class ProgramOptions
|
|
||||||
{
|
|
||||||
[Option('r', "repository", Required = true, HelpText = "Path to repository.")]
|
|
||||||
public string RepositoryPath { 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; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
## Readme
|
|
||||||
This is obsolete program to update all icons, fonts and pack each theme files from ``customize/*`` to ``themes/`` folder in ``.tar`` format (non-compressed).
|
|
||||||
|
|
||||||
Now, every time you create new commit on ``master`` branch and change something in ``assets/icons``, ``customize`` or ``font`` folder, [github action](https://github.com/features/actions) bot will update all files (as defined in [this file](https://github.com/AdisonCavani/distro-grub-themes/blob/master/.github/workflows/update-content.yml)).
|
|
||||||
<br>To check all workflows, go [here](https://github.com/AdisonCavani/distro-grub-themes/actions).
|
|
Loading…
Add table
Reference in a new issue