valdo icon indicating copy to clipboard operation
valdo copied to clipboard

Valdo extension for VS Code

Open pervoj opened this issue 4 years ago • 37 comments

Are you also planning to create a Valdo extension for VS Code?

pervoj avatar Jun 20 '21 13:06 pervoj

I'll have to think about it.

Prince781 avatar Jun 20 '21 19:06 Prince781

I think there was some discussion in a thread on GNOME Builder's issue page about templating too. I hope that, for now at least, a command-line interface is rather useful.

Prince781 avatar Jun 21 '21 07:06 Prince781

@Prince781 will you mind if I make one

ghost avatar Aug 19 '21 17:08 ghost

@Abdallah-Moh feel free

Prince781 avatar Aug 19 '21 17:08 Prince781

thanks

ghost avatar Aug 19 '21 17:08 ghost

is there any way to enter the app name and the rest when calling the command

ghost avatar Sep 01 '21 17:09 ghost

@Abdallah-Moh not currently. What context do you need to use this in?

Prince781 avatar Sep 01 '21 18:09 Prince781

the vscode extention

ghost avatar Sep 01 '21 18:09 ghost

the user will be required to have valdo installed

ghost avatar Sep 01 '21 18:09 ghost

the vscode extention

I mean more specifically, how to you plan to have the plugin interact with valdo? For example, are you going to rewrite the prompt in JS and intend to call valdo to instantiate the template? Walk me through your proposal.

Prince781 avatar Sep 01 '21 19:09 Prince781

What I will do is get all the required info from the user then use a node module to run valdo --data in here

ghost avatar Sep 01 '21 20:09 ghost

@Abdallah-Moh how will you determine what information you need? Don't you need to analyze the template?

Prince781 avatar Sep 01 '21 21:09 Prince781

Yes I will get the template type at the beginning

ghost avatar Sep 01 '21 22:09 ghost

@Abdallah-Moh so it looks like I'll need to make some changes to valdo for you. What do you think of this API?

% valdo eos --list-vars
{
        "PROGRAM_NAME": {
            "summary": "the name of the program",
            "default": "/${PROJECT_NAME}/\\w+/\\u\\0/(\\w)?\\W+(\\w)?(\\w*)/\\1\\u\\2\\L\\3\\E/^\\w/\\u\\0/",
            "pattern": "^[[:word:]-]+$"
        },
        "PROJECT_SUMMARY": {
            "summary": "a very short summary of the project",
            "default": "a new app for elementary OS"
        },
        "PROJECT_CATEGORIES": {
            "summary": "categories (semicolon-separated)",
            "pattern": "^((AudioVideo|Audio|Video|Development|Education|Game|Graphics|Network|Office|Science|Settings|System|Utility);)+$"
        },
        "PROJECT_KEYWORDS": {
            "summary": "keywords (semicolon-separated)",
            "default": "/${PROJECT_NAME}/\\W+/;/^;+//\\w+/\\L\\0\\E/[^;]$/\\0;/",
            "pattern": "^(\\w+;)+$"
        }
}
% valdo --list-builtin-vars
# will list all built-in variables
% valdo eos -DPROGRAM_NAME='valdo' -DPROJECT_VERSION='1.0.0' \
 -DPROJECT_SUMMARY='a templating engine for Vala' -DPROJECT_CATEGORIES='System;Utility;' \
 -DPROJECT_KEYWORDS='vala,templating' -o $DIRECTORY

Note, this is an example of how it would work with the eos template.

Prince781 avatar Sep 03 '21 17:09 Prince781

looks nice for me

ghost avatar Sep 03 '21 17:09 ghost

@Abdallah-Moh checkout and build wip/commands and try getting your frontend to work with Valdo

Prince781 avatar Sep 10 '21 04:09 Prince781

@Prince781 is there an arg to get a list of all the templates

ghost avatar Sep 10 '21 18:09 ghost

@Abdallah-Moh you can just run valdo and it'll print out all of the templates. The output should be easy to parse.

e.g.

% valdo | tail -n +3 | awk '{print $1}'
lib
new
gtk
swifty-gtk4
eos

Prince781 avatar Sep 10 '21 23:09 Prince781

Maybe it would be better to parse the output using JS for better running support on Windows.

pervoj avatar Sep 11 '21 07:09 pervoj

@pervoj Why would someone create a vala project on windows, and js is what is used to create vscode extentions

ghost avatar Sep 11 '21 07:09 ghost

@Abdallah-Moh Maybe someone can start working on Linux and continue working on Windows. Otherwise, I think it's a shame to have a non-multiplatform extension for the multiplatform Valdo.

Yes, I know, I meant that I think it's better to parse the output right in the extension code.

pervoj avatar Sep 11 '21 08:09 pervoj

@pervoj The extension will need valdo to run and valdo is not available for windows

ghost avatar Sep 11 '21 08:09 ghost

@Abdallah-Moh You can compile Valdo on Windows without any problems. I also talked with @Prince781 about packaging for MSYS2 (where these commands but are available).

It's up to you, it was just a suggestion.

pervoj avatar Sep 11 '21 08:09 pervoj

the extension will work if valdo is installed so yes it can work on windows if you install valdo

ghost avatar Sep 11 '21 08:09 ghost

@Abdallah-Moh the example command I gave demonstrates that it's simple to parse valdo's output using a regex. I did not intend for you to execute that command.

Prince781 avatar Sep 11 '21 15:09 Prince781

I know

ghost avatar Sep 11 '21 15:09 ghost

Is the feature added?

ghost avatar Sep 22 '21 11:09 ghost

Try wip/commands branch

pervoj avatar Sep 22 '21 13:09 pervoj

I was busy but now I have time to work on the extension you can find it here https://github.com/Abdallah-Moh/vs-valdo

ghost avatar Sep 22 '21 13:09 ghost

@Abdallah-Moh so it looks like I'll need to make some changes to valdo for you. What do you think of this API?

% valdo eos --list-vars
{
        "PROGRAM_NAME": {
            "summary": "the name of the program",
            "default": "/${PROJECT_NAME}/\\w+/\\u\\0/(\\w)?\\W+(\\w)?(\\w*)/\\1\\u\\2\\L\\3\\E/^\\w/\\u\\0/",
            "pattern": "^[[:word:]-]+$"
        },
        "PROJECT_SUMMARY": {
            "summary": "a very short summary of the project",
            "default": "a new app for elementary OS"
        },
        "PROJECT_CATEGORIES": {
            "summary": "categories (semicolon-separated)",
            "pattern": "^((AudioVideo|Audio|Video|Development|Education|Game|Graphics|Network|Office|Science|Settings|System|Utility);)+$"
        },
        "PROJECT_KEYWORDS": {
            "summary": "keywords (semicolon-separated)",
            "default": "/${PROJECT_NAME}/\\W+/;/^;+//\\w+/\\L\\0\\E/[^;]$/\\0;/",
            "pattern": "^(\\w+;)+$"
        }
}
% valdo --list-builtin-vars
# will list all built-in variables
% valdo eos -DPROGRAM_NAME='valdo' -DPROJECT_VERSION='1.0.0' \
 -DPROJECT_SUMMARY='a templating engine for Vala' -DPROJECT_CATEGORIES='System;Utility;' \
 -DPROJECT_KEYWORDS='vala,templating' -o $DIRECTORY

Note, this is an example of how it would work with the eos template.

@Prince781 can this return an array of objects and each object will contain the name and the rest

ghost avatar Sep 22 '21 13:09 ghost