Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce simple CLI for managing themes #3

Open
EmilyGraceSeville7cf opened this issue Dec 3, 2021 · 26 comments
Open

Introduce simple CLI for managing themes #3

EmilyGraceSeville7cf opened this issue Dec 3, 2021 · 26 comments
Labels
enhancement New feature or request

Comments

@EmilyGraceSeville7cf
Copy link

EmilyGraceSeville7cf commented Dec 3, 2021

I think it will be useful to have CLI like this:

yuki {add | remove | rename | duplicate} <THEME-NAME>
@Dragon-0609
Copy link
Owner

Dragon-0609 commented Dec 3, 2021

OK,. I'll make a CLI version.
Don't forget, it will be like program version (which can't be integrated to the PascalABC.NET IDE), so it won't be able to set background image, to change colors of some parts of UI. Also, you will have to restart the IDE to apply the theme.
Commands will be like this:

Main Commands: 
yuki { select | duplicate | export | import | rename | delete | edit } <THEME-NAME>

Settings:
yuki setting { path=<Path to Pascal> | ask=<true or false> | mode=<Light or Advanced> }

Help:
yuki help:

yuki help -> Show all commands
yuki themes -> Show all themes names
yuki select <THEME-NAME> -> select theme (you will be able to write like this:

	 yuki export <name> | yuki delete <name> -> yuki export | yuki delete

yuki export -> export selected theme or theme by name to the PascalABC.NET
...

@EmilyGraceSeville7cf
Copy link
Author

EmilyGraceSeville7cf commented Dec 3, 2021

Just several suggestions (correct me where I am wrong):

Main commands: 
  yuki { select | duplicate | export | import | rename | delete | edit | settings | list } <THEME-NAME> [{-h | --help}] [{-v | --version}]

Global settings:
  yuki settings --path PATH_TO_PASCAL [{-q|--quiet}] [--mode { Light | Advanced }]

  - Default is not --quiet mode.
  - Default is Light mode.

I use command-line syntax key for describing relationships between options and --long|-short options. If CLI is good I will create Fish/Bash autocomplete for it so user will not memorize all syntax. ;)

@Dragon-0609
Copy link
Owner

Dragon-0609 commented Dec 3, 2021

What does : [{-v | --version}] ?
If user want to get current version, he will be able to use yuki [-v | --version].
What does : [{-q|--quiet}] ? I don't understand why it's necessary.

BTW can you write documentation for help commands? I'll make main function, so you will just need to write like this:

// Input : yuki list -h
private void getHelp(string text){
	switch (text) {
		case "list": {
			Console.WriteLine("Show all themes' names"); 
			// output is "Show all themes names"
		}
		break;
		case "export": {
			Console.WriteLine("export selected theme or theme by name to the PascalABC.NET"); 
			// output is "export selected theme or theme by name to the PascalABC.NET"
		}
		break;
		// ...etc.
	}
}

I don't like to write documentation, so can you do it? I'll be very glad if you help me. If you have any questions about commands, just ask me. I'll explain you.

@Dragon-0609
Copy link
Owner

Why settings in Main commands? What will be there if there're global settings like path to pascal and etc?

@EmilyGraceSeville7cf
Copy link
Author

EmilyGraceSeville7cf commented Dec 3, 2021

What does : [{-v | --version}] ?

It lists current version of CLI tool like for sed:

sed (GNU sed) 4.7
Packaged by Debian
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Jay Fenlason, Tom Lord, Ken Pizzini,
Paolo Bonzini, Jim Meyering, and Assaf Gordon.
GNU sed home page: <https://www.gnu.org/software/sed/>.
General help using GNU software: <https://www.gnu.org/gethelp/>.
E-mail bug reports to: <bug-sed@gnu.org>.

Square brackets mean that this option is not required and curly braces mean that only -h or --help may be provided. There is no sense in both options because they have the same application. But actually nothing bad will happen if user provide both of them. Many Unix tools allow to duplicate this option without any consequences. I've just included {...} to highlight that:

There is no sense in both options...

What does : [{-q|--quiet}] ?

It is a replacement for ask. Many GNU commands have this option so I decided to replace ask with it to make CLI simpler.

I'll make main function, so you will just need to write like this:

I think it's better to use some framework for option parsing like this one. There is no sense to reinvent the wheel. ;)

I don't like to write documentation, so can you do it? I'll be very glad if you help me. If you have any questions about commands, just ask me. I'll explain you.

Why not? I can help you. :)

@Dragon-0609
Copy link
Owner

It lists current version of CLI tool like for sed:

sed (GNU sed) 4.7
Packaged by Debian
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Jay Fenlason, Tom Lord, Ken Pizzini,
Paolo Bonzini, Jim Meyering, and Assaf Gordon.
GNU sed home page: <https://www.gnu.org/software/sed/>.
General help using GNU software: <https://www.gnu.org/gethelp/>.
E-mail bug reports to: <bug-sed@gnu.org>.

I'll make the CLI as a common Console application. I don't think there will be things like that. Also, the CLI will be for windows. At the moment I'm developing plugin for PascalABC of windows. I haven't written anything for another OS.

I think it's better to use some framework for option parsing

Thanks for suggestion. I'll use that.

I can help you

Thanks.

@EmilyGraceSeville7cf
Copy link
Author

EmilyGraceSeville7cf commented Dec 3, 2021

Why settings in Main commands?

You've written:

yuki setting { path= | ask= | mode= }

so I thought setting (or settings as I suggested) is a subcommand for yuki.

@Dragon-0609
Copy link
Owner

I thought setting (or settings as I suggested) is a subcommand for yuki

Ok.

@EmilyGraceSeville7cf
Copy link
Author

EmilyGraceSeville7cf commented Dec 3, 2021

I've created a simple prototype for option parsing (view main.cs). To change input arguments for program show all Repl.it configs such as shown below:

image

and change everything after double dash in run = "dotnet run -- select --regex 'My regex'" to any other arguments. If I give you access by your nickname on Repl.it you will be able edit code right there (even in real time). :)

Git on Repl.it

@Dragon-0609 Dragon-0609 added the enhancement New feature or request label Dec 4, 2021
@Dragon-0609
Copy link
Owner

I need time to learn .NET Core.
I'll write here, when I learn it. OK?

@EmilyGraceSeville7cf
Copy link
Author

Okay

@Dragon-0609
Copy link
Owner

Dragon-0609 commented Dec 8, 2021

Hi, I'm learning .NET Core. I found this info here:

.NET Core can reference a .NET Standard DLL
.NET Framework can reference a .NET Standard DLL

.NET Core cannot reference a .NET Framework DLL (or visa versa).

If you have for example a .NET Standard Project, you cannot reference .NET Framework and the .NET Core framework.
It's one or the other.

image

My version of .NET Core is 6. I tried to reference Yuki Theme.Core (which was built in .NET Framework 4.5.2), it works. But I'm not sure what will happen at runtime 🤔. I'll write CLI version, but it won't be cross-platform, it will be just for Windows.

I have read that .NET Standart and .NET Core is cross-platform.
I think about writing Yuki Theme.Core in .NET Standart, but it will be problematic 😢. Maybe I'll do it next year, but not this year.

@EmilyGraceSeville7cf
Copy link
Author

Please email me because I am going to send you a link for russian C# VK group. Maybe there your question will be solved. :)

@Dragon-0609
Copy link
Owner

Dragon-0609 commented Dec 10, 2021

а не проще ли попытаться существующий откомпилировать под нужный тебе

Пожалуйста, дайте ссылку на существующий проект, а то мне не до поисков нормально реализированного CLI.

Я запутался. Как выяснилось, System.Drawing.Image нету в Net Core, что очень расстраивает.
Я сделал так, чтобы все основные команды шли через Yuki Theme.Core.CLI. Если убрать System.Drawing.Image, то придётся многое изменить и возможно появятся дубликаты методов, которых я остерегаюсь, ибо мне лень потом менять их всех.
Думаю, я напишу CLI в Net Framework. Мне так удобнее и проблем будет меньше. Только сейчас задумался, зачем я вообще пытался написать в Net Core, когда я могу в Net Framework.

@EmilyGraceSeville7cf
Copy link
Author

EmilyGraceSeville7cf commented Dec 10, 2021

Уже давала, но могу снова - вот. Если уж совсем будет туго с переносом этого проекта на .NET Framework, можно свой с нуля написать, главное, чтобы парсинг опций был адекватным, совместимый с GNU getopt.

@Dragon-0609
Copy link
Owner

А вы про то. Ну, я научился пользоваться ей. Вот то что я сделал:

using System;
using System.Collections.Generic;
using System.CommandLine;
using CommandLine;
using CommandLine.Text;

namespace ConsoleApp
{
	
	public abstract class AutoHelp
	{
		[Option('h', "help", Required = false, HelpText = "Show help for specific command.", Default = false)]
		public bool ShowHelp { get; set; }
	}

	[Verb("duplicate", HelpText = "Duplicate the specified themes\nduplicate <from> <to>")]
	public class DuplicateCommand
	{
		
		[Value( 0, HelpText = "Duplicate <from> <to>", MetaName = "Paths")]
		public IEnumerable<string> Paths {get; set;}
	}

	[Verb("list", HelpText = "Show list of themes")]
	public class ListCommand
	{
	}

	[Verb("export", HelpText = "Export selected theme\nexport <name>")]
	public class ExportCommand
	{
		[Value( 0, HelpText = "Export <name>", MetaName = "Theme")]
		public string Name {get; set;}
	}

	[Verb("import", HelpText = "Import theme by the path\nimport <path>")]
	public class ImportCommand
	{
		[Value( 0, HelpText = "Import <path>", MetaName = "Theme")]
		public string Path {get; set;}
	}

	[Verb("delete", HelpText = "Delete selected theme\ndelete <name>")]
	public class DeleteCommand
	{
		[Value( 0, HelpText = "Delete <name>", MetaName = "Theme")]
		public string Name {get; set;}
	}

	[Verb("settings", HelpText = "Change Setting")]
	public class SettingsCommand
	{
		[Option('p', "path", Required = false, HelpText = "Set path to pascal.")]
		public string Path { get; set; }
	
		[Option('q', "quiet", Required = false, HelpText = "Ask if there're other themes.")]
		public string Quiet { get; set; }
	
		[Option('m', "mode", Required = false, HelpText = "Setting mode. There're two options: Light and Advanced")]
		public string Mode { get; set; }
	}
	
	class ConsoleApp
	{

		static void Main (string [] args)
		{
			HelpText oHelpText;
			
			Yuki_Theme.Core.CLI.connectAndGet ();
			
			var parser = new Parser (parserSettings =>
			{
				parserSettings.AutoHelp = true;
				parserSettings.AutoVersion = true;
				parserSettings.CaseInsensitiveEnumValues = false;
				parserSettings.CaseSensitive = true;
				parserSettings.EnableDashDash = true;
				parserSettings.IgnoreUnknownArguments = false;
			});

			var res = parser
				.ParseArguments <DuplicateCommand, ListCommand, ExportCommand, ImportCommand, DeleteCommand,
					SettingsCommand> (args);
			
			res.WithParsed <DuplicateCommand> (o =>
			   {
				   // if (o.ShowHelp)
				   // {
				   // Console.WriteLine (o.select);
				   // }else
				   // {
				   Console.WriteLine ("Duplicate Command");
				   foreach (string path in o.Paths)
				   {
					   
					   Console.WriteLine (path);
				   }
				   // }
				   // Console.WriteLine (o.ShowHelp);
			   }).WithParsed <ListCommand> (o =>
			   {
				   // Console.WriteLine ("Showed list");
				   foreach (string name in Yuki_Theme.Core.CLI.names)
				   {
					   Console.WriteLine (name);
				   }
			   }).WithParsed <ExportCommand> (o =>
			   {
				   
			   }).WithParsed <ImportCommand> (o =>
			   {
				   
			   }).WithParsed <DeleteCommand> (o =>
			   {
				   
			   }).WithParsed <SettingsCommand> (o =>
			   {
				   
			   })
			   .WithNotParsed(errors =>
			   {
				   HelpText helpText = null;
				   if (errors.IsHelp () || errors.IsVersion ())
				   {
					   helpText = HelpText.AutoBuild(res);
					   Console.WriteLine (helpText);
				   } else
				   {
					   foreach (var error in errors)
						   switch (error)
						   {
							   case BadVerbSelectedError badVerbSelectedError :
								   Console.WriteLine ($"There is no \"{badVerbSelectedError.Token}\" subcommand.");
								   break;

							   case UnknownOptionError unknownOptionError :
								   Console.WriteLine ($"There is no \"{unknownOptionError.Token}\" option.");
								   break;

							   case MissingValueOptionError:
								   helpText = HelpText.AutoBuild(res);
								   Console.WriteLine (helpText);
								   break;
							   // Handler other appropriate exceptions downhere.
							   default :
								   Console.WriteLine ($"The {error} happened.");
								   break;
						   }
				   }
			   });
			
			// oHelpText = HelpText.AutoBuild(res, x => x, x => x);

			// Console.WriteLine(oHelpText);
		}
	}
}


@Dragon-0609
Copy link
Owner

Если уж совсем будет туго с переносом этого проекта на .NET Framework

Всё что я успел написать, он вверху: ↑

@Dragon-0609
Copy link
Owner

Мне не будет трудно переписать, т.к. толком и ничего не написал, а только понял тот парсер.

@Dragon-0609
Copy link
Owner

Оказывается тот парсер, который вы отправили совместим с Net Framework, так что мне теперь не нужно искать другой парсер. Спасибо вам.
Я только что прописал команду list. вот результаты:

yuki list
Darcula
Dracula
Github Dark
Github Light
Monokai Dark
Monokai Light
Nightshade
Oblivion
Shades of Purple
BlendS: Maika
BunnySenpai: Mai Dark
BunnySenpai: Mai Light
DDLC: Monika Dark
DDLC: Monika Light
DDLC: Natsuki Dark
DDLC: Natsuki Light
DDLC: Sayori Dark
DDLC: Sayori Light
DDLC: Yuri Dark
DDLC: Yuri Light
DM: Kanna
DM: Tohru
DR: Mioda Ibuki Dark
DR: Mioda Ibuki Light
DTWMMN: Hayase Nagatoro
DxD: Rias Crimson
DxD: Rias Onyx
EroManga: Sagiri
EVA: Katsuragi Misato
EVA: Rei
Franxx: Zero Two Dark
Franxx: Zero Two Light
FutureDiary: Gasai Yuno
Gate: Rory Mercury
JahySama: Jahy
Kakegurui: Jabami Yumeko
KillLaKill: Ryuko Dark
KillLaKill: Ryuko Light
KillLaKill: Satsuki Dark
KillLaKill: Satsuki Light
KonoSuba: Aqua
KonoSuba: Darkness Dark
KonoSuba: Darkness Light
KonoSuba: Megumin
LoveLive: Sonoda Umi
LS: Konata
Monogatari: Hanekawa Tsubasa
MonsterMusume: Miia
NekoPara: Azuki
NekoPara: Chocola
NekoPara: Cinnamon
NekoPara: Coconut
NekoPara: Maple Dark
NekoPara: Maple Light
NekoPara: Shigure
NekoPara: Vanilla
OreGairu: Yukinoshita Yukino
OreImo: Kirino
QQ: Nakano Miku
QQ: Nakano Nino
Re:Zero: Beatrice
Re:Zero: Echidna
Re:Zero: Emilia Dark
Re:Zero: Emilia Light
Re:Zero: Ram
Re:Zero: Rem
SAO: Asuna Dark
SAO: Asuna Light
SG: Makise Kurisu
TypeMoon: Astolfo
TypeMoon: Gray
TypeMoon: Ishtar Dark
TypeMoon: Ishtar Light
TypeMoon: Tohsaka Rin
Vocaloid: Hatsune Miku
YuruCamp: Shima Rin

@EmilyGraceSeville7cf
Copy link
Author

Всегда рада помочь. :З

@Dragon-0609
Copy link
Owner

Я добавил очень простую CLI версию. Он не подходит для редактирования (изменения цветов и изображений) тем. Он может выполнить простые команды как export, import, delete, copy, rename и list. Я возможно сделаю её лучше в следующей версии.
#10

@Dragon-0609
Copy link
Owner

Dragon-0609 commented Dec 24, 2021

Я решил добавить возможность редактирования (изменения цветов и изображений) тем в версии 4, т.е. в этой версии. Синтаксис будет таким:

yuki edit <THEME NAME>  [ -d | --definition { Default | LineNumber | Digit | Comment | String | KeyWord | BeginEnd | Image | Sticker } ] <VALUES>

Для  цветов:
Фон:	{ -b | --bg }
Текст: 	{ -t | --text }
если хотите поменять только цвет текста то:

yuki edit Test -d Default -t #DDDDDD

если хотите поменять только цвет фона то:

yuki edit Test -d Default -b #323232

Для изображений:

{ -o | --opacity } [ -a | --align { left | center | right } ] { -p | --path }
Например:
yuki edit Test -d Image -p "C:\Test\wallpaper.png" -a center -o 15

Будет примерно так.

@Dragon-0609
Copy link
Owner

Я добавил возможность изменять цвета и изображения. Я тестировал их недостаточно, чтобы убедиться, что они работают как надо.
Кстати, я добавил команду 'fields' и 'allfields'. Они показывают возможные параметры (Definition), которые можно изменять с помощью edit.

@Dragon-0609
Copy link
Owner

Dragon-0609 commented Apr 21, 2022

Я добавил команду обновить для CLI. Чтобы использовать просто напишите:
yuki features -u "<Путь>".

Я хочу добавить специальные команды, которые будут доступны только в CLI.

Такие как: Экспорт настроек, Импорт настроек, Включить логи (для плагина), Включить стили (для плагина), Отключить глубокую интеграцию с IDE (для плагина).

@Dragon-0609
Copy link
Owner

Добавил авто-завершение с tab для CLI:

CLI_Completion

Сейчас оно работает для основных команд и для имён тем.

@Dragon-0609
Copy link
Owner

Dragon-0609 commented Jul 16, 2022

В следующей бета версии вы сможете использовать Yuki Theme CLI (yuki.exe) чтобы применять темы для IDE в Linux-е.

Screenshot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants