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

Process api hook #2131

Merged
merged 16 commits into from
Oct 10, 2018
Merged
Show file tree
Hide file tree
Changes from 8 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
5 changes: 5 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ If available, link to an existing issue this PR fixes. For example:

## TODO

Feel free to open the PR and ask for help

- [] New (API-)documentation for new features exist (Note: API-docs are enough, additional docs are in `help/markdown`)
- [] unit or integration test exists (or short reasoning why it doesn't make sense)

> Note: Consider using the `CreateProcess` API which can be tested more easily, see https://github.com/fsharp/FAKE/pull/2131/files#diff-4fb4a77e110fbbe8210205dfe022389b for an example (the changes in the `DotNet.Testing.NUnit` module)

- [] (if new module) the module has been linked from the "Modules" menu, edit `help/templates/template.cshtml`, linking to the API-reference is fine.
- [] (if new module) the module is in the correct namespace
- [] (if new module) the module is added to Fake.sln (`dotnet sln Fake.sln add src/app/Fake.*/Fake.*.fsproj`)
Expand Down
23 changes: 18 additions & 5 deletions src/app/Fake.Core.Process/CmdLineParsing.fs
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,19 @@ module internal CmdLineParsing =

type FilePath = string

/// Helper functions for proper command line parsing
module Args =
/// Convert the given argument list to a conforming windows command line string, escapes parameter in quotes if needed (currently always but this might change).
let toWindowsCommandLine args = CmdLineParsing.windowsArgvToCommandLine args
/// Escape the given argument list according to a unix shell (bash)
let toLinuxShellCommandLine args =
System.String.Join(" ", args |> Seq.map CmdLineParsing.escapeCommandLineForShell)

/// Read a windows command line string into its arguments
let fromWindowsCommandLine cmd = CmdLineParsing.windowsCommandLineToArgv cmd


/// Represents a list of arguments
type Arguments =
{ Args : string array }
internal { Args : string array }
static member Empty = { Args = [||] }
/// See https://msdn.microsoft.com/en-us/library/17w5ykft.aspx
static member OfWindowsCommandLine cmd =
Expand All @@ -126,6 +130,15 @@ type Arguments =
member x.ToWindowsCommandLine = Args.toWindowsCommandLine x.Args
member x.ToLinuxShellCommandLine = Args.toLinuxShellCommandLine x.Args

static member OfArgs args = { Args = args }
/// Create a new arguments object from the given list of arguments
static member OfArgs (args:string seq) = { Args = args |> Seq.toArray }
/// Create a new arguments object from a given startinfo-conforming-escaped command line string.
static member OfStartInfo cmd = Arguments.OfWindowsCommandLine cmd
member internal x.ToStartInfo = CmdLineParsing.toProcessStartInfo x.Args
/// Create a new command line string which can be used in a ProcessStartInfo object.
member x.ToStartInfo = CmdLineParsing.toProcessStartInfo x.Args

module Arguments =
let withPrefix s (a:Arguments) =
Arguments.OfArgs(Seq.append s a.Args)
let append s (a:Arguments) =
Arguments.OfArgs(Seq.append a.Args s)
1 change: 1 addition & 0 deletions src/app/Fake.Core.Process/Fake.Core.Process.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="VisibleTo.fs" />
<Compile Include="GuardedAwaitObservable.fs" />
<Compile Include="Event.fs" />
<Compile Include="Async.fs" />
Expand Down
Loading