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

Refactor the project cracker into a new file et al. #618

Merged
merged 8 commits into from
Oct 24, 2020
4 changes: 2 additions & 2 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"isRoot": true,
"tools": {
"fake-cli": {
"version": "5.20.0",
"version": "5.20.3",
"commands": [
"fake"
]
},
"paket": {
"version": "5.245.2",
"version": "5.249.0",
"commands": [
"paket"
]
Expand Down
4 changes: 2 additions & 2 deletions paket.dependencies
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version 5.247.4
version 5.249.0
source https://api.nuget.org/v3/index.json
framework: auto-detect
storage: none
Expand All @@ -9,7 +9,7 @@ nuget CommandLineParser ~> 2.8
nuget Dotnet.ProjInfo
nuget Dotnet.ProjInfo.Workspace
nuget Newtonsoft.Json
nuget Suave 2.1.1
nuget Suave
nuget System.Memory

# Used to create notebook docs with mybinder links that work
Expand Down
659 changes: 190 additions & 469 deletions paket.lock

Large diffs are not rendered by default.

451 changes: 18 additions & 433 deletions src/FSharp.Formatting.CommandTool/BuildCommand.fs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<Link>Common\AssemblyInfo.fs</Link>
</Compile>
<Compile Include="Options.fs" />
<Compile Include="ProjectCracker.fs" />
<Compile Include="BuildCommand.fs" />
<Compile Include="Program.fs" />
</ItemGroup>
Expand Down
14 changes: 12 additions & 2 deletions src/FSharp.Formatting.CommandTool/Options.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,20 @@ module Common =
| Some "" -> None
| _ -> Some (List.ofSeq a)

// https://stackoverflow.com/questions/4126351
let private pairs (xs: _ seq) = seq {
use enumerator = xs.GetEnumerator()
while enumerator.MoveNext() do
let first = enumerator.Current
if enumerator.MoveNext() then
let second = enumerator.Current
yield first, second
}

let evalPairwiseStrings a =
match Seq.tryExactlyOne a with
| Some "" -> None
| _ -> a |> Seq.pairwise |> List.ofSeq |> Some
| _ -> a |> pairs |> List.ofSeq |> Some
wallymathieu marked this conversation as resolved.
Show resolved Hide resolved

let evalPairwiseStringsNoOption a =
evalPairwiseStrings a |> Option.defaultValue []
Expand All @@ -24,4 +34,4 @@ module Common =
let waitForKey b =
if b then
printf "\nPress any key to continue ..."
System.Console.ReadKey() |> ignore
System.Console.ReadKey() |> ignore
22 changes: 2 additions & 20 deletions src/FSharp.Formatting.CommandTool/Program.fs
Original file line number Diff line number Diff line change
@@ -1,29 +1,11 @@

module FSharp.Formatting.CommandTool.Main

open CommandLine

let printAssemblies msg =
printfn "%s. Loaded Assemblies:" msg
System.AppDomain.CurrentDomain.GetAssemblies()
|> Seq.choose (fun a -> try Some (a.GetName().FullName, a.Location) with _ -> None)
|> Seq.iter (fun (n, l) -> printfn "\t- %s: %s" n l)


[<EntryPoint>]
let main argv =
try
CommandLine.Parser.Default.ParseArguments(argv, typeof<BuildCommand>, typeof<WatchCommand>)
CommandLine.Parser.Default.ParseArguments<BuildCommand, WatchCommand>(argv)
.MapResult(
(fun (opts: BuildCommand) -> opts.Execute()),
(fun (opts: WatchCommand) -> opts.Execute()),
(fun errs -> 1));
with e ->
let e =
match e with
| :? System.AggregateException as ex -> ex.InnerExceptions.[0]
| _ -> e
//printAssemblies "(DIAGNOSTICS) Documentation failed"
printfn "fsdocs.exe failed: %O" e
1
//reraise()
(fun _ -> 1))
Loading