Skip to content

Commit

Permalink
Merge pull request #1090 from bentayloruk/1082-print-cmd-line-warning
Browse files Browse the repository at this point in the history
WIP Warn when fail to parse cmd line args. Close #1082
  • Loading branch information
forki committed Jan 20, 2016
2 parents a2f122c + 3ec08d8 commit 627d687
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/app/FAKE/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ try

//None of the new style args parsed, so revert to the old skool.
| Choice2Of2(ex) ->

// #1082 print a warning as we've been invoked with invalid OR old-style args.
traceImportant "Error parsing command line arguments. You have a mistake in your args, or are using the pre-2.1.8 argument style:"
exceptionAndInnersToString ex |> traceImportant
trace "Attempting to run with pre-version 2.18 argument style, for backwards compat."

if (cmdArgs.Length = 2 && paramIsHelp cmdArgs.[1]) || (cmdArgs.Length = 1 && List.length buildScripts = 0) then printUsage () else
match Boot.ParseCommandLine(cmdArgs) with
| None ->
Expand Down
10 changes: 7 additions & 3 deletions src/app/FakeLib/TraceHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ let traceFAKE fmt = Printf.ksprintf (fun text -> postMessage (ImportantMessage t
let traceError error = postMessage (ErrorMessage error)

open Microsoft.FSharp.Core.Printf
/// Traces an exception details (in red)
let traceException (ex:Exception) =

/// Converts an exception and its inner exceptions to a nice string.
let exceptionAndInnersToString (ex:Exception) =
let sb = Text.StringBuilder()
let delimeter = String.replicate 50 "*"
let nl = Environment.NewLine
Expand Down Expand Up @@ -85,7 +86,10 @@ let traceException (ex:Exception) =
if (e.InnerException <> null)
then printException e.InnerException (count+1)
printException ex 1
sb.ToString() |> traceError
sb.ToString()

/// Traces an exception details (in red)
let traceException (ex:Exception) = exceptionAndInnersToString ex |> traceError

/// Traces the EnvironmentVariables
let TraceEnvironmentVariables() =
Expand Down

0 comments on commit 627d687

Please sign in to comment.