Skip to content

Commit

Permalink
support specify project file
Browse files Browse the repository at this point in the history
  • Loading branch information
jichang committed Mar 18, 2018
1 parent 2357662 commit 0c2df18
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions src/Mechanic.NetcoreCliTool/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,35 @@ open System.IO
open Mechanic
open Mechanic.Files
open Mechanic.GraphAlg
open Mechanic.Files

[<EntryPoint>]
let main argv =
let projectDirectory =
let loadFromDir dir =
Directory.EnumerateFiles dir
|> Seq.map ProjectFile.tryLoad
|> Seq.filter Option.isSome
|> Seq.map (fun projectFile -> projectFile.Value)

let projectFiles =
if argv.Length = 0 then
Environment.CurrentDirectory
loadFromDir Environment.CurrentDirectory
else
Path.Combine (Environment.CurrentDirectory, argv.[0])
try
let path = Path.Combine (Environment.CurrentDirectory, argv.[0])
let attributes = File.GetAttributes path
if attributes.HasFlag FileAttributes.Directory then
loadFromDir path
else
let fi = FileInfo path
match fi.Extension with
| ".fsproj" ->
let projectFile = ProjectFile.loadFromFile path
seq {
yield projectFile
}
| _ -> Seq.empty
with
| _ -> Seq.empty

let solve (n, m) projectFile =
printfn "Project %s" projectFile.FileName
Expand All @@ -30,12 +50,6 @@ let main argv =
|> printfn "%A"
(n, m + 1)

let projectFiles =
Directory.EnumerateFiles projectDirectory
|> Seq.map ProjectFile.tryLoad
|> Seq.filter Option.isSome
|> Seq.map (fun projectFile -> projectFile.Value)

if Seq.isEmpty projectFiles then
printfn "No *.fsproj files found in %s" Environment.CurrentDirectory
else
Expand Down

0 comments on commit 0c2df18

Please sign in to comment.