Skip to content

Commit

Permalink
Improving the vs CLI with correct profile handling, removed obsolete …
Browse files Browse the repository at this point in the history
…subcommands, implemented a temporary help file
  • Loading branch information
checkroom committed Nov 21, 2024
1 parent 75a481c commit aea7b4a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 14 deletions.
16 changes: 16 additions & 0 deletions commons/HELP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Using VS
========

- **help**: this command.
- **version**: to display versions of the dependencies it has been built with.
- **run**: `vs run FILE_PATH` to run an application.
- **test**: `vs test FILE_PATH ACTIONS_PATH ` to test an application.
- **editor**: to quickly run the embedded editor.
- **hub**: to open the use hub.

If no argument is provided, it will open the default `hub` page.

Variables of environment
------------------------

To be written
40 changes: 26 additions & 14 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,16 @@ int run(const char* path, const char *entry, const char* profile){
}
}

int test(const char* path, const char *entry_file, const char* action_file, const char* profile){
std::cerr<<"Not implemented yet\n";
return 1;
}

int main(int argc, char **argv) {
const char* profile = getenv("VS_PROFILE");

if(argc==1){
return run(argv[0],"vs://hub.xml",nullptr);
return run(argv[0],"vs://hub.xml",profile);
}
else{
if(strcmp(argv[1],"run")==0){
Expand All @@ -79,7 +86,16 @@ int main(int argc, char **argv) {
return 1;
}

auto t =run(argv[0],argv[2],nullptr);
auto t =run(argv[0],argv[2],profile);
return t;
}
else if(strcmp(argv[1],"test")==0){
if(argc<2){
std::cerr<<"This application in test mode requires the path to a valid xml file or native component as first argument, and an xml file of actions as its second\n";
return 1;
}

auto t =test(argv[0],argv[2],argv[3],profile);
return t;
}
else if(strcmp(argv[1],"version")==0){
Expand All @@ -96,23 +112,19 @@ int main(int argc, char **argv) {
<<"libuv: "<<versions.libuv<<"\n";
return 0;
}
else if(strcmp(argv[1],"run-profile")==0){
if(argc<3){
std::cerr<<"This application requires the path to a profile and a valid xml file or native component passed as first argument\n";
return 1;
}

return run(argv[0],argv[3],argv[2]);
}
else if(strcmp(argv[1],"editor")==0){
return run(argv[0],"vs://editor.xml",nullptr);
return run(argv[0],"vs://editor.xml",profile);
}
else if(strcmp(argv[1],"hub")==0){
return run(argv[0],"vs://hub.xml",nullptr);
return run(argv[0],"vs://hub.xml",profile);
}
else if(strcmp(argv[1],"help")==0){
std::cerr<<"Not implemented\n";
return 0;
const char docs[] = {
#embed "../../commons/HELP.md" suffix(, 0)
};
//TODO: Show in window as a markdown once the processor is ready.
std::cout<<docs<<"\n";
return 0;
}
else{
std::cerr<<"Unrecognized option\n";
Expand Down

0 comments on commit aea7b4a

Please sign in to comment.