Skip to content

Commit 52f8095

Browse files
committed
Improve method docs and fix template builds
1 parent ef48c05 commit 52f8095

File tree

10 files changed

+40
-16
lines changed

10 files changed

+40
-16
lines changed

FileTemplater.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,19 @@
33

44
namespace DarkRift.Cli
55
{
6+
/// <summary>
7+
/// Handles templating of generated files.
8+
/// </summary>
69
class FileTemplater
710
{
11+
/// <summary>
12+
/// Template the given path file's path and content.
13+
/// </summary>
14+
/// <param name="filePath">The path of the file.</param>
15+
/// <param name="resourceName">The name of the resource being created.</param>
16+
/// <param name="darkriftVersion">The version of DarkRift being used.</param>
17+
/// <param name="tier">The tier of DarkRift being used.</param>
18+
/// <param name="platform">The platform the DarkRift being used was built for.</param>
819
public static void TemplateFileAndPath(string filePath, string resourceName, string darkriftVersion, ServerTier tier, ServerPlatform platform)
920
{
1021
string resolvedPath = TemplateString(filePath, resourceName, darkriftVersion, tier, platform);
@@ -24,6 +35,14 @@ public static void TemplateFileAndPath(string filePath, string resourceName, str
2435
File.Delete(resolvedPath);
2536
}
2637

38+
/// <summary>
39+
/// Template the given string.
40+
/// </summary>
41+
/// <param name="text">The string to template.</param>
42+
/// <param name="resourceName">The name of the resource being created.</param>
43+
/// <param name="darkriftVersion">The version of DarkRift being used.</param>
44+
/// <param name="tier">The tier of DarkRift being used.</param>
45+
/// <param name="platform">The platform the DarkRift being used was built for.</param>
2746
private static string TemplateString(string text, string resourceName, string darkriftVersion, ServerTier tier, ServerPlatform platform)
2847
{
2948
// Keep files containing __k__

Program.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class NewOptions
3535
public string Version { get; set; }
3636

3737
[Option('p', "pro", Default = false, HelpText = "Use the pro version.")]
38-
public bool Tier { get; set; }
38+
public bool Pro { get; set; }
3939

4040
[Option('s', "platform", Default = ServerPlatform.Framework, HelpText = "Specify the .NET platform of the server to use.")]
4141
public ServerPlatform Platform { get; set; }
@@ -104,11 +104,16 @@ private static int New(NewOptions opts)
104104

105105
Console.WriteLine($"Cleaning up extracted artifacts...");
106106

107+
string version = opts.Version ?? VersionManager.GetLatestDarkRiftVersion();
108+
107109
foreach (string path in Directory.GetFiles(targetDirectory, "*.*", SearchOption.AllDirectories))
108-
FileTemplater.TemplateFileAndPath(path, Path.GetFileName(targetDirectory), opts.Version ?? VersionManager.GetLatestDarkRiftVersion(), opts.Tier ? ServerTier.Pro : ServerTier.Free, opts.Platform);
110+
FileTemplater.TemplateFileAndPath(path, Path.GetFileName(targetDirectory), version, opts.Pro ? ServerTier.Pro : ServerTier.Free, opts.Platform);
109111

110112
Console.WriteLine(Output.Green($"Created '{Path.GetFileName(targetDirectory)}'"));
111113

114+
// Make sure that the given DarkRift version is actually downloaded.
115+
VersionManager.GetInstallationPath(version, opts.Pro ? ServerTier.Pro : ServerTier.Free, opts.Platform);
116+
112117
return 0;
113118
}
114119

@@ -122,7 +127,7 @@ private static int Run(RunOptions opts)
122127
project.Save();
123128
}
124129

125-
string path = VersionManager.GetInstallationPath(Version.Parse(project.Runtime.Version), project.Runtime.Tier, project.Runtime.Platform);
130+
string path = VersionManager.GetInstallationPath(project.Runtime.Version, project.Runtime.Tier, project.Runtime.Platform);
126131
if (path == null)
127132
return 1;
128133

@@ -191,7 +196,7 @@ private static int Get(GetOptions opts)
191196

192197
private static int Pull(PullOptions opts)
193198
{
194-
string path = VersionManager.GetInstallationPath(Version.Parse(opts.Version), opts.Tier ? ServerTier.Pro : ServerTier.Free, opts.Platform);
199+
string path = VersionManager.GetInstallationPath(opts.Version, opts.Tier ? ServerTier.Pro : ServerTier.Free, opts.Platform);
195200

196201
if (path == null)
197202
return 1;

VersionManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ class VersionManager
2828
/// <param name="pro">Whether the pro version should be used.</param>
2929
/// <param name="netStandard">Whether the .NET Standard build should be used.</param>
3030
/// <returns>The path to the installation, or null, if it cannot be provided.</returns>
31-
public static string GetInstallationPath(Version version, ServerTier tier, ServerPlatform platform)
31+
public static string GetInstallationPath(string version, ServerTier tier, ServerPlatform platform)
3232
{
33-
string fullPath = Path.Combine(USER_DR_DIR, "installed", tier.ToString().ToLower(), platform.ToString().ToLower(), version.ToString());
33+
string fullPath = Path.Combine(USER_DR_DIR, "installed", tier.ToString().ToLower(), platform.ToString().ToLower(), version);
3434

3535
if (!Directory.Exists(fullPath))
3636
{

templates/log-writer/__n____c__.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<Reference Include="DarkRift" />
10-
<Reference Include="DarkRift.Server" />
9+
<Reference Include="$(UserProfile)/.darkrift/installed/Free/Framework/2.3.1/Lib/DarkRift.dll" />
10+
<Reference Include="$(UserProfile)/.darkrift/installed/Free/Framework/2.3.1/Lib/DarkRift.Server.dll" />
1111
</ItemGroup>
1212
</Project>

templates/log-writer/src/LogWriter1__c__.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
using DarkRift.Server;
44

5-
namespace $__n__
5+
namespace __n__
66
{
77
/// <summary>
88
/// A simple log writer that outputs to standard out.

templates/network-listener/__n____c__.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<Reference Include="DarkRift" />
10-
<Reference Include="DarkRift.Server" />
9+
<Reference Include="$(UserProfile)/.darkrift/installed/Free/Framework/2.3.1/Lib/DarkRift.dll" />
10+
<Reference Include="$(UserProfile)/.darkrift/installed/Free/Framework/2.3.1/Lib/DarkRift.Server.dll" />
1111
</ItemGroup>
1212
</Project>

templates/network-listener/src/NetworkListener1__c__.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using DarkRift;
44
using DarkRift.Server;
55

6-
namespace $__n__
6+
namespace __n__
77
{
88
/// <summary>
99
/// A simple network listener template.

templates/network-listener/src/NetworkServerConnection1__c__.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using DarkRift;
44
using DarkRift.Server;
55

6-
namespace $__n__
6+
namespace __n__
77
{
88
/// <summary>
99
/// An unimplemented NetworkServerConnection.

templates/plugin/__n____c__.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<Reference Include="DarkRift" />
10-
<Reference Include="DarkRift.Server" />
9+
<Reference Include="$(UserProfile)/.darkrift/installed/__t__/__p__/__v__/Lib/DarkRift.dll" />
10+
<Reference Include="$(UserProfile)/.darkrift/installed/__t__/__p__/__v__/Lib/DarkRift.Server.dll" />
1111
</ItemGroup>
1212
</Project>

templates/plugin/src/Plugin1__c__.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using DarkRift;
44
using DarkRift.Server;
55

6-
namespace $__n__
6+
namespace __n__
77
{
88
/// <summary>
99
/// A simple command that relays messages to all clients

0 commit comments

Comments
 (0)