Skip to content

Create empty DGui skeleton project #518

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions source/dub/commandline.d
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ class InitCommand : Command {
"minimal - simple \"hello world\" project (default)",
"vibe.d - minimal HTTP server based on vibe.d",
"deimos - skeleton for C header bindings",
"dgui - minimal DGui application",
]);
}

Expand All @@ -345,11 +346,11 @@ class InitCommand : Command {
// Checks if argument uses current method of specifying project type.
if (free_args.length)
{
if (["vibe.d", "deimos", "minimal"].canFind(free_args[0]))
if (["vibe.d", "deimos", "minimal", "dgui"].canFind(free_args[0]))
{
m_buildType = free_args[0];
free_args = free_args[1 .. $];
logInfo("Deprecated use of init type. Use --type=[vibe.d | deimos | minimal] in future.");
logInfo("Deprecated use of init type. Use --type=[vibe.d | deimos | minimal | dgui] in future.");
}
}
dub.createEmptyPackage(Path(dir), free_args, m_buildType);
Expand Down
28 changes: 28 additions & 0 deletions source/dub/init.d
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ void initPackage(Path root_path, string[string] deps, string type)
case "minimal": initMinimalPackage(root_path, deps); break;
case "vibe.d": initVibeDPackage(root_path, deps); break;
case "deimos": initDeimosPackage(root_path, deps); break;
case "dgui": initDGuiPackage(root_path, deps); break;
}
writeGitignore(root_path);
}
Expand Down Expand Up @@ -101,6 +102,33 @@ void initDeimosPackage(Path root_path, string[string] deps)
createDirectory(root_path ~ "deimos");
}

void initDGuiPackage(Path root_path, string[string] deps)
{
if("dgui" !in deps)
deps["dgui"] = "~>1.0.1";

writePackageJson(root_path, "A minimal DGui application", deps);
createDirectory(root_path ~ "source");
write((root_path ~ "source/app.d").toNativeString(),
q{import dgui.all;

class MainForm: Form
{
public this()
{
this.text = "DGui Form";
this.size = Size(500, 400);
this.startPosition = FormStartPosition.centerScreen;
}
}

int main(string[] args)
{
return Application.run(new MainForm());
}
});
}

void writePackageJson(Path root_path, string description, string[string] dependencies = null, string[string] addFields = null)
{
import std.algorithm : map;
Expand Down