Skip to content
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

Fix powershell errors and update C# #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
171 changes: 36 additions & 135 deletions src/dotnet/Cljr/Cljr.csproj
Original file line number Diff line number Diff line change
@@ -1,141 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackAsTool>true</PackAsTool>
<ToolCommandName>cljr</ToolCommandName>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageOutputPath>./nupkg</PackageOutputPath>
<Version>0.1.0-alpha2</Version>
<PackageId>Clojure.$(AssemblyName)</PackageId>
<Authors>ClojureCLR contributors</Authors>
<Description>The deps.edn-powered CLI tool for ClojureCLR.</Description>
<Copyright>ClojureCLR contributors, 2024</Copyright>
<PackageProjectUrl>https://github.com/clojure/clr.core.cli</PackageProjectUrl>
<RepositoryUrl>https://github.com/clojure/clr.core.cli</RepositoryUrl>
<PackageLicenseExpression>EPL-1.0</PackageLicenseExpression>
<PackageTags>Clojure;ClojureCLR</PackageTags>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<LangVersion>12</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackAsTool>true</PackAsTool>
<ToolCommandName>cljr</ToolCommandName>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageOutputPath>./nupkg</PackageOutputPath>
<Version>0.1.0-alpha2</Version>
<PackageId>Clojure.$(AssemblyName)</PackageId>
<Authors>ClojureCLR contributors</Authors>
<Description>The deps.edn-powered CLI tool for ClojureCLR.</Description>
<Copyright>ClojureCLR contributors, 2024</Copyright>
<PackageProjectUrl>https://github.com/clojure/clr.core.cli</PackageProjectUrl>
<RepositoryUrl>https://github.com/clojure/clr.core.cli</RepositoryUrl>
<PackageLicenseExpression>EPL-1.0</PackageLicenseExpression>
<PackageTags>Clojure;ClojureCLR</PackageTags>
</PropertyGroup>

<ItemGroup>
<None Remove="clojure\run\exec.cljc" />
<None Remove="clojure\tools\cli.cljc" />
<None Remove="clojure\tools\cli\api.cljc" />
<None Remove="clojure\tools\cli\help.cljc" />
<None Remove="clojure\tools\deps.cljc" />
<None Remove="clojure\tools\deps\deps.edn" />
<None Remove="clojure\tools\deps\extensions.cljc" />
<None Remove="clojure\tools\deps\extensions\deps.cljc" />
<None Remove="clojure\tools\deps\extensions\git.cljc" />
<None Remove="clojure\tools\deps\extensions\local.cljc" />
<None Remove="clojure\tools\deps\license-abbrev.edn" />
<None Remove="clojure\tools\deps\script\make_classpath2.cljc" />
<None Remove="clojure\tools\deps\script\parse.cljc" />
<None Remove="clojure\tools\deps\script\resolve_tags.cljc" />
<None Remove="clojure\tools\deps\specs.cljc" />
<None Remove="clojure\tools\deps\tool.cljc" />
<None Remove="clojure\tools\deps\tree.cljc" />
<None Remove="clojure\tools\deps\util\concurrent.clj" />
<None Remove="clojure\tools\deps\util\concurrent.cljr" />
<None Remove="clojure\tools\deps\util\dir.cljc" />
<None Remove="clojure\tools\deps\util\io.cljc" />
<None Remove="clojure\tools\deps\util\session.cljc" />
<None Remove="clojure\tools\gitlibs.cljc" />
<None Remove="clojure\tools\gitlibs\config.cljr" />
<None Remove="clojure\tools\gitlibs\impl.cljr" />
<None Remove="example-deps.edn" />
<None Remove="tools\run-clojure-main.ps1" />
<None Remove="tools\run-clojure-main.sh" />
</ItemGroup>
<ItemGroup>
<None Remove="clojure\**"/>
<None Remove="example-deps.edn"/>
<None Remove="tools\**"/>
</ItemGroup>

<ItemGroup>
<Content Include="clojure\run\exec.cljc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="clojure\tools\cli.cljc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="clojure\tools\cli\api.cljc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="clojure\tools\cli\help.cljc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="clojure\tools\deps.cljc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="clojure\tools\deps\deps.edn">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="clojure\tools\deps\extensions.cljc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="clojure\tools\deps\extensions\deps.cljc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="clojure\tools\deps\extensions\git.cljc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="clojure\tools\deps\extensions\local.cljc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="clojure\tools\deps\license-abbrev.edn">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="clojure\tools\deps\script\make_classpath2.cljc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="clojure\tools\deps\script\parse.cljc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="clojure\tools\deps\script\resolve_tags.cljc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="clojure\tools\deps\specs.cljc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="clojure\tools\deps\tool.cljc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="clojure\tools\deps\tree.cljc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="clojure\tools\deps\util\concurrent.clj">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="clojure\tools\deps\util\concurrent.cljr">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="clojure\tools\deps\util\dir.cljc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="clojure\tools\deps\util\io.cljc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="clojure\tools\deps\util\session.cljc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="clojure\tools\gitlibs.cljc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="clojure\tools\gitlibs\config.cljr">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="clojure\tools\gitlibs\impl.cljr">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="example-deps.edn">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="tools\run-clojure-main.sh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="tools\run-clojure-main.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="clojure\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="tools\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="example-deps.edn">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

</Project>
10 changes: 5 additions & 5 deletions src/dotnet/Cljr/CommandLineParser.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace Cljr;


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

// PowerShell workaround
if (Program.IsWindows)
if (Platform.IsWindows)
{
switch (arg)
{
Expand All @@ -36,7 +35,8 @@ public static ParseItems Parse(string[] args)
}

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

if (arg == "-Sresolve-tags")
return items.SetError("Option changed, use: clj -X:deps git-resolve-tags");
Expand Down Expand Up @@ -106,6 +106,7 @@ public static ParseItems Parse(string[] args)
default:
return items.SetError($"Unknown option: {arg}");
}

continue;
}

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

return items;
}

}
}
28 changes: 15 additions & 13 deletions src/dotnet/Cljr/ParseItems.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
namespace Cljr;

public enum EMode { Version, Help, Repl, Tool, Exec, Main }
public enum EMode
{
Version,
Help,
Repl,
Tool,
Exec,
Main
}

public class ParseItems
{
Expand Down Expand Up @@ -35,19 +43,13 @@ public void SetCommandAliases(EMode mode, string? alias)
CommandAliases[mode] = alias;
}

public string GetCommandAlias(EMode mode)
{
if (CommandAliases.TryGetValue(mode, out var alias))
return alias;
else
return string.Empty;
}

public bool TryGetCommandAlias(EMode mode, out string alias)
{
return CommandAliases.TryGetValue(mode, value: out alias);
}
public string GetCommandAlias(EMode mode) =>
CommandAliases.TryGetValue(mode, out var alias)
? alias
: string.Empty;

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

public void AddFlag(string flag)
{
Expand Down
11 changes: 11 additions & 0 deletions src/dotnet/Cljr/Platform.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Reflection;
using System.Runtime.InteropServices;

namespace Cljr;

public static class Platform
{
public static bool IsWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
public static string HomeDir => Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
public static readonly string Version = Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "unknown";
}
Loading