Skip to content

Commit f8a1199

Browse files
authored
Merge pull request #1 from lucasteles/refactoring
Fix powershell errors and update C#
2 parents 9f14ebf + 5469181 commit f8a1199

File tree

5 files changed

+529
-657
lines changed

5 files changed

+529
-657
lines changed

src/dotnet/Cljr/Cljr.csproj

+36-136
Original file line numberDiff line numberDiff line change
@@ -1,141 +1,41 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<OutputType>Exe</OutputType>
5-
<TargetFrameworks>net6.0;net8.0;net9.0</TargetFrameworks>
6-
<ImplicitUsings>enable</ImplicitUsings>
7-
<Nullable>enable</Nullable>
8-
<PackAsTool>true</PackAsTool>
9-
<ToolCommandName>cljr</ToolCommandName>
10-
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
11-
<PackageOutputPath>./nupkg</PackageOutputPath>
12-
<Version>0.1.0-alpha6</Version>
13-
<PackageId>Clojure.$(AssemblyName)</PackageId>
14-
<Authors>ClojureCLR contributors</Authors>
15-
<Description>The deps.edn-powered CLI tool for ClojureCLR.</Description>
16-
<Copyright>ClojureCLR contributors, 2024</Copyright>
17-
<PackageProjectUrl>https://github.com/clojure/clr.core.cli</PackageProjectUrl>
18-
<RepositoryUrl>https://github.com/clojure/clr.core.cli</RepositoryUrl>
19-
<PackageLicenseExpression>EPL-1.0</PackageLicenseExpression>
20-
<PackageTags>Clojure;ClojureCLR</PackageTags>
21-
</PropertyGroup>
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
6+
<LangVersion>12</LangVersion>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
<PackAsTool>true</PackAsTool>
10+
<ToolCommandName>cljr</ToolCommandName>
11+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
12+
<PackageOutputPath>./nupkg</PackageOutputPath>
13+
<Version>0.1.0-alpha6</Version>
14+
<PackageId>Clojure.$(AssemblyName)</PackageId>
15+
<Authors>ClojureCLR contributors</Authors>
16+
<Description>The deps.edn-powered CLI tool for ClojureCLR.</Description>
17+
<Copyright>ClojureCLR contributors, 2025</Copyright>
18+
<PackageProjectUrl>https://github.com/clojure/clr.core.cli</PackageProjectUrl>
19+
<RepositoryUrl>https://github.com/clojure/clr.core.cli</RepositoryUrl>
20+
<PackageLicenseExpression>EPL-1.0</PackageLicenseExpression>
21+
<PackageTags>Clojure;ClojureCLR</PackageTags>
22+
</PropertyGroup>
2223

23-
<ItemGroup>
24-
<None Remove="clojure\run\exec.cljc" />
25-
<None Remove="clojure\tools\cli.cljc" />
26-
<None Remove="clojure\tools\cli\api.cljc" />
27-
<None Remove="clojure\tools\cli\help.cljc" />
28-
<None Remove="clojure\tools\deps.cljc" />
29-
<None Remove="clojure\tools\deps\deps.edn" />
30-
<None Remove="clojure\tools\deps\extensions.cljc" />
31-
<None Remove="clojure\tools\deps\extensions\deps.cljc" />
32-
<None Remove="clojure\tools\deps\extensions\git.cljc" />
33-
<None Remove="clojure\tools\deps\extensions\local.cljc" />
34-
<None Remove="clojure\tools\deps\license-abbrev.edn" />
35-
<None Remove="clojure\tools\deps\script\make_classpath2.cljc" />
36-
<None Remove="clojure\tools\deps\script\parse.cljc" />
37-
<None Remove="clojure\tools\deps\script\resolve_tags.cljc" />
38-
<None Remove="clojure\tools\deps\specs.cljc" />
39-
<None Remove="clojure\tools\deps\tool.cljc" />
40-
<None Remove="clojure\tools\deps\tree.cljc" />
41-
<None Remove="clojure\tools\deps\util\concurrent.cljr" />
42-
<None Remove="clojure\tools\deps\util\dir.cljc" />
43-
<None Remove="clojure\tools\deps\util\io.cljc" />
44-
<None Remove="clojure\tools\deps\util\session.cljc" />
45-
<None Remove="clojure\tools\gitlibs.cljc" />
46-
<None Remove="clojure\tools\gitlibs\config.cljr" />
47-
<None Remove="clojure\tools\gitlibs\impl.cljr" />
48-
<None Remove="deps.edn" />
49-
<None Remove="example-deps.edn" />
50-
<None Remove="tools\run-clojure-main.ps1" />
51-
<None Remove="tools\run-clojure-main.sh" />
52-
</ItemGroup>
53-
54-
<ItemGroup>
55-
<Content Include="clojure\run\exec.cljc">
56-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
57-
</Content>
58-
<Content Include="clojure\tools\cli.cljc">
59-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
60-
</Content>
61-
<Content Include="clojure\tools\cli\api.cljc">
62-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
63-
</Content>
64-
<Content Include="clojure\tools\cli\help.cljc">
65-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
66-
</Content>
67-
<Content Include="clojure\tools\deps.cljc">
68-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
69-
</Content>
70-
<Content Include="clojure\tools\deps\deps.edn">
71-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
72-
</Content>
73-
<Content Include="clojure\tools\deps\extensions.cljc">
74-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
75-
</Content>
76-
<Content Include="clojure\tools\deps\extensions\deps.cljc">
77-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
78-
</Content>
79-
<Content Include="clojure\tools\deps\extensions\git.cljc">
80-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
81-
</Content>
82-
<Content Include="clojure\tools\deps\extensions\local.cljc">
83-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
84-
</Content>
85-
<Content Include="clojure\tools\deps\license-abbrev.edn">
86-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
87-
</Content>
88-
<Content Include="clojure\tools\deps\script\make_classpath2.cljc">
89-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
90-
</Content>
91-
<Content Include="clojure\tools\deps\script\parse.cljc">
92-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
93-
</Content>
94-
<Content Include="clojure\tools\deps\script\resolve_tags.cljc">
95-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
96-
</Content>
97-
<Content Include="clojure\tools\deps\specs.cljc">
98-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
99-
</Content>
100-
<Content Include="clojure\tools\deps\tool.cljc">
101-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
102-
</Content>
103-
<Content Include="clojure\tools\deps\tree.cljc">
104-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
105-
</Content>
106-
<Content Include="clojure\tools\deps\util\concurrent.cljr">
107-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
108-
</Content>
109-
<Content Include="clojure\tools\deps\util\dir.cljc">
110-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
111-
</Content>
112-
<Content Include="clojure\tools\deps\util\io.cljc">
113-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
114-
</Content>
115-
<Content Include="clojure\tools\deps\util\session.cljc">
116-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
117-
</Content>
118-
<Content Include="clojure\tools\gitlibs.cljc">
119-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
120-
</Content>
121-
<Content Include="clojure\tools\gitlibs\config.cljr">
122-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
123-
</Content>
124-
<Content Include="clojure\tools\gitlibs\impl.cljr">
125-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
126-
</Content>
127-
<Content Include="deps.edn">
128-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
129-
</Content>
130-
<Content Include="example-deps.edn">
131-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
132-
</Content>
133-
<Content Include="tools\run-clojure-main.sh">
134-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
135-
</Content>
136-
<Content Include="tools\run-clojure-main.ps1">
137-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
138-
</Content>
139-
</ItemGroup>
24+
<ItemGroup>
25+
<None Remove="clojure\**"/>
26+
<None Remove="example-deps.edn"/>
27+
<None Remove="tools\**"/>
28+
</ItemGroup>
14029

30+
<ItemGroup>
31+
<Content Include="clojure\**">
32+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
33+
</Content>
34+
<Content Include="tools\**">
35+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
36+
</Content>
37+
<Content Include="example-deps.edn">
38+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
39+
</Content>
40+
</ItemGroup>
14141
</Project>

src/dotnet/Cljr/CommandLineParser.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace Cljr;
22

3-
43
public static class CommandLineParser
54
{
65
static readonly List<string> DeprecatedPrefixes = new() { "-R", "-C", "-O" };
@@ -19,7 +18,7 @@ public static ParseItems Parse(string[] args)
1918
var arg = args[i++];
2019

2120
// PowerShell workaround
22-
if (Program.IsWindows)
21+
if (Platform.IsWindows)
2322
{
2423
switch (arg)
2524
{
@@ -36,7 +35,8 @@ public static ParseItems Parse(string[] args)
3635
}
3736

3837
if (StartsWithDeprecatedPrefix(arg))
39-
return items.SetError($"{arg[..2]} is no longer supported, use -A with repl, -M for main, -X for exec, -T for tool");
38+
return items.SetError(
39+
$"{arg[..2]} is no longer supported, use -A with repl, -M for main, -X for exec, -T for tool");
4040

4141
if (arg == "-Sresolve-tags")
4242
return items.SetError("Option changed, use: clj -X:deps git-resolve-tags");
@@ -106,6 +106,7 @@ public static ParseItems Parse(string[] args)
106106
default:
107107
return items.SetError($"Unknown option: {arg}");
108108
}
109+
109110
continue;
110111
}
111112

@@ -165,5 +166,4 @@ public static ParseItems Parse(string[] args)
165166

166167
return items;
167168
}
168-
169-
}
169+
}

src/dotnet/Cljr/ParseItems.cs

+15-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
namespace Cljr;
22

3-
public enum EMode { Version, Help, Repl, Tool, Exec, Main }
3+
public enum EMode
4+
{
5+
Version,
6+
Help,
7+
Repl,
8+
Tool,
9+
Exec,
10+
Main
11+
}
412

513
public class ParseItems
614
{
@@ -35,19 +43,13 @@ public void SetCommandAliases(EMode mode, string? alias)
3543
CommandAliases[mode] = alias;
3644
}
3745

38-
public string GetCommandAlias(EMode mode)
39-
{
40-
if (CommandAliases.TryGetValue(mode, out var alias))
41-
return alias;
42-
else
43-
return string.Empty;
44-
}
45-
46-
public bool TryGetCommandAlias(EMode mode, out string alias)
47-
{
48-
return CommandAliases.TryGetValue(mode, value: out alias);
49-
}
46+
public string GetCommandAlias(EMode mode) =>
47+
CommandAliases.TryGetValue(mode, out var alias)
48+
? alias
49+
: string.Empty;
5050

51+
public bool TryGetCommandAlias(EMode mode, out string? alias) =>
52+
CommandAliases.TryGetValue(mode, value: out alias);
5153

5254
public void AddFlag(string flag)
5355
{

src/dotnet/Cljr/Platform.cs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System.Reflection;
2+
using System.Runtime.InteropServices;
3+
4+
namespace Cljr;
5+
6+
public static class Platform
7+
{
8+
public static bool IsWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
9+
public static string HomeDir => Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
10+
public static readonly string Version = Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "unknown";
11+
}

0 commit comments

Comments
 (0)