How to make project with main application and cli application in the same folder?

alex ashustrich at gmail.com
Sun Apr 21 08:44:38 UTC 2024


Hi guys. Trying to play with vibe-d and want to create separate 
web app, and cli app which can add admin users. When I just keep 
both files app.d and cli.d in source folder, I get an error that 
I can't have more then 1 main function.

I already asked chatGPT, and it replied that I need to use 
subpackages. I put cli into separate folder, and now I get an 
error, that it can't see some model from main app(I want to reuse 
UserModel for both, cli and web app). How can I make it visible 
for both cli and web without making copy?

My folder:

project
  | -- dub.json
  | -- source/
        | -- app.d
        | -- user_model.d
  | -- cli/
        | -- source
               | -- cli.d

dub.json:
{
	"name": "project",
	"subPackages": [
         {
             "name": "app",
             "sourcePaths": ["source"],
             "mainSourceFile": "source/app.d",
             "targetType": "executable",
			"dependencies": {
				"vibe-d": "~>0.9"
			}
         },
         {
             "name": "cli",
             "sourcePaths": ["cli/source"],
             "mainSourceFile": "cli/source/cli.d",
             "targetType": "executable",
			"dependencies": {
				"vibe-d": "~>0.9"
			}
         }
     ]
}


More information about the Digitalmars-d-learn mailing list