parent
a9c824578b
commit
2d444993e7
@ -0,0 +1,27 @@ |
|||||||
|
PROJECTS=git-guts cli git-guts/tests
|
||||||
|
|
||||||
|
build: |
||||||
|
dotnet build --nologo --no-restore cli/cli.fsproj
|
||||||
|
build-tests: |
||||||
|
dotnet build --nologo --no-restore git-guts/tests/tests.fsproj
|
||||||
|
|
||||||
|
publish: |
||||||
|
for proj in $(PROJECTS); do \
|
||||||
|
rm -rf $$proj/bin/Release ; \
|
||||||
|
rm -rf $$proj/obj/Release ; \
|
||||||
|
done
|
||||||
|
dotnet publish --nologo --no-restore --configuration Release cli/cli.fsproj
|
||||||
|
|
||||||
|
tests: |
||||||
|
dotnet test --nologo --no-restore git-guts/tests/
|
||||||
|
|
||||||
|
clean: |
||||||
|
for proj in $(PROJECTS); do \
|
||||||
|
rm -rf $$proj/bin ; \
|
||||||
|
rm -rf $$proj/obj ; \
|
||||||
|
done
|
||||||
|
|
||||||
|
restore: |
||||||
|
for proj in $(PROJECTS); do \
|
||||||
|
dotnet restore $$proj/*.fsproj ; \
|
||||||
|
done
|
@ -0,0 +1,44 @@ |
|||||||
|
open System |
||||||
|
open System.IO |
||||||
|
open Argu |
||||||
|
open git_guts |
||||||
|
|
||||||
|
type CliArguments = |
||||||
|
| [<AltCommandLine("-r")>] Repo of path:string |
||||||
|
interface IArgParserTemplate with |
||||||
|
member s.Usage = |
||||||
|
match s with |
||||||
|
| Repo _ -> "specify the git repo directory." |
||||||
|
|
||||||
|
type CliExiter() = |
||||||
|
interface IExiter with |
||||||
|
member __.Name = "CliExiter" |
||||||
|
member __.Exit( msg, code ) = |
||||||
|
if code = ErrorCode.HelpText then |
||||||
|
// show the help text |
||||||
|
printfn "%s" msg |
||||||
|
exit 0 |
||||||
|
else |
||||||
|
// show the error message (sans help text) |
||||||
|
let pos = msg.IndexOf "USAGE:" |
||||||
|
let msg2 = msg.Substring( 0, pos-1 ) |
||||||
|
printfn "%s" msg2 |
||||||
|
printfn "Use --help to get help." |
||||||
|
exit 1 |
||||||
|
|
||||||
|
[<EntryPoint>] |
||||||
|
let main argv = |
||||||
|
|
||||||
|
// parse the command-line arguments |
||||||
|
let programName = System.AppDomain.CurrentDomain.FriendlyName |
||||||
|
let parser = ArgumentParser.Create<CliArguments>( programName=programName, helpTextMessage="Examine the guts of a git repo.", errorHandler=CliExiter() ) |
||||||
|
let results = parser.Parse argv |
||||||
|
let repoDir = Path.GetFullPath( results.GetResult( Repo, defaultValue="." ) ) |
||||||
|
if not (Directory.Exists repoDir) then |
||||||
|
failwith "Can't find git repo directory." |
||||||
|
|
||||||
|
// initialize |
||||||
|
let gitGuts = GitGuts( repoDir ) |
||||||
|
printfn "git guts: %A" gitGuts.repoDir |
||||||
|
|
||||||
|
0 |
@ -0,0 +1,21 @@ |
|||||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||||
|
|
||||||
|
<PropertyGroup> |
||||||
|
<OutputType>Exe</OutputType> |
||||||
|
<TargetFramework>net5.0</TargetFramework> |
||||||
|
<RootNamespace>git_guts_cli</RootNamespace> |
||||||
|
</PropertyGroup> |
||||||
|
|
||||||
|
<ItemGroup> |
||||||
|
<Compile Include="Program.fs" /> |
||||||
|
</ItemGroup> |
||||||
|
|
||||||
|
<ItemGroup> |
||||||
|
<PackageReference Include="Argu" Version="6.1.1" /> |
||||||
|
</ItemGroup> |
||||||
|
|
||||||
|
<ItemGroup> |
||||||
|
<ProjectReference Include="..\git-guts\git-guts.fsproj" /> |
||||||
|
</ItemGroup> |
||||||
|
|
||||||
|
</Project> |
@ -0,0 +1,4 @@ |
|||||||
|
namespace git_guts |
||||||
|
|
||||||
|
type GitGuts( repoDir: string ) = |
||||||
|
member this.repoDir = repoDir |
@ -0,0 +1,13 @@ |
|||||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||||
|
|
||||||
|
<PropertyGroup> |
||||||
|
<TargetFramework>net5.0</TargetFramework> |
||||||
|
<RootNamespace>git_guts</RootNamespace> |
||||||
|
<GenerateDocumentationFile>true</GenerateDocumentationFile> |
||||||
|
</PropertyGroup> |
||||||
|
|
||||||
|
<ItemGroup> |
||||||
|
<Compile Include="Library.fs" /> |
||||||
|
</ItemGroup> |
||||||
|
|
||||||
|
</Project> |
@ -0,0 +1 @@ |
|||||||
|
module Program = let [<EntryPoint>] main _ = 0 |
@ -0,0 +1,11 @@ |
|||||||
|
namespace tests |
||||||
|
|
||||||
|
open System |
||||||
|
open Microsoft.VisualStudio.TestTools.UnitTesting |
||||||
|
|
||||||
|
[<TestClass>] |
||||||
|
type TestClass () = |
||||||
|
|
||||||
|
[<TestMethod>] |
||||||
|
member this.TestMethodPassing () = |
||||||
|
Assert.IsTrue( true ) |
@ -0,0 +1,22 @@ |
|||||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||||
|
|
||||||
|
<PropertyGroup> |
||||||
|
<TargetFramework>net5.0</TargetFramework> |
||||||
|
|
||||||
|
<IsPackable>false</IsPackable> |
||||||
|
<GenerateProgramFile>false</GenerateProgramFile> |
||||||
|
</PropertyGroup> |
||||||
|
|
||||||
|
<ItemGroup> |
||||||
|
<Compile Include="Tests.fs" /> |
||||||
|
<Compile Include="Program.fs" /> |
||||||
|
</ItemGroup> |
||||||
|
|
||||||
|
<ItemGroup> |
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" /> |
||||||
|
<PackageReference Include="MSTest.TestAdapter" Version="2.1.1" /> |
||||||
|
<PackageReference Include="MSTest.TestFramework" Version="2.1.1" /> |
||||||
|
<PackageReference Include="coverlet.collector" Version="1.3.0" /> |
||||||
|
</ItemGroup> |
||||||
|
|
||||||
|
</Project> |
Loading…
Reference in new issue