Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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: 3 additions & 2 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"isRoot": true,
"tools": {
"fantomas": {
"version": "5.2.1",
"version": "8.0.0-beta-002",
"commands": [
"fantomas"
]
],
"rollForward": false
}
}
}
8 changes: 5 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ fsharp_max_record_width=60
fsharp_max_array_or_list_width=120
fsharp_max_value_binding_width=120
fsharp_max_function_binding_width=120
fsharp_max_dot_get_expression_width=120
fsharp_multiline_block_brackets_on_same_column=true
fsharp_multiline_bracket_style=stroustrup
fsharp_newline_before_multiline_computation_expression=false
fsharp_multi_line_lambda_closing_newline=true
fsharp_blank_lines_around_nested_multiline_expressions=false
fsharp_experimental_stroustrup_style=true

[*.fsx]
fsharp_newline_before_multiline_computation_expression=true
8 changes: 5 additions & 3 deletions .github/workflows/Build and publish nuget package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v7

- name: Setup .NET Core
uses: actions/setup-dotnet@v5
uses: actions/setup-dotnet@v6
with:
dotnet-version: 8.0.x
dotnet-version: |
8.0.x
10.0.x

- name: Use build.fsx
env:
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/Run tests for PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v7

- name: Setup .NET Core
uses: actions/setup-dotnet@v5
uses: actions/setup-dotnet@v6
with:
dotnet-version: 8.0.x
dotnet-version: |
8.0.x
10.0.x

- name: Use build.fsx
run: dotnet fsi ./build.fsx -- -p test
123 changes: 61 additions & 62 deletions Fun.Build.Cli/History.fs
Original file line number Diff line number Diff line change
Expand Up @@ -101,67 +101,66 @@ type History =
?withLastArgs: bool,
?promptForContinuation: bool,
?continuationItems: Collections.Generic.List<HistoryItem>
) =
asyncResult {
let withLastArgs = defaultArg withLastArgs false
let scriptFile = Path.GetFileName history.Pipeline.Script
let scriptDir = Path.GetDirectoryName history.Pipeline.Script
let promptForContinuation = defaultArg promptForContinuation false

let table = Table()
table.ShowHeaders <- false
table.AddColumns("", "") |> ignore
table.AddRow("Script", $"[green]{scriptFile}[/]") |> ignore
table.AddRow("Pipeline", $"[bold green]{history.Pipeline.Name}[/]") |> ignore
table.AddRow("WorkingDir", $"[green]{scriptDir}[/]") |> ignore
table.AddRow("Arguments", history.Args) |> ignore

AnsiConsole.Write table
AnsiConsole.MarkupLine("New arguments (leave empty to use the one from history):")

let args =
if withLastArgs then
history.Args
else
let text = TextPrompt<string>("> ")
text.AllowEmpty <- true
let newArgs = AnsiConsole.Prompt text
if String.IsNullOrEmpty newArgs then history.Args else newArgs

) = asyncResult {
let withLastArgs = defaultArg withLastArgs false
let scriptFile = Path.GetFileName history.Pipeline.Script
let scriptDir = Path.GetDirectoryName history.Pipeline.Script
let promptForContinuation = defaultArg promptForContinuation false

let table = Table()
table.ShowHeaders <- false
table.AddColumns("", "") |> ignore
table.AddRow("Script", $"[green]{scriptFile}[/]") |> ignore
table.AddRow("Pipeline", $"[bold green]{history.Pipeline.Name}[/]") |> ignore
table.AddRow("WorkingDir", $"[green]{scriptDir}[/]") |> ignore
table.AddRow("Arguments", history.Args) |> ignore

AnsiConsole.Write table
AnsiConsole.MarkupLine("New arguments (leave empty to use the one from history):")

let args =
if withLastArgs then
history.Args
else
let text = TextPrompt<string>("> ")
text.AllowEmpty <- true
let newArgs = AnsiConsole.Prompt text
if String.IsNullOrEmpty newArgs then history.Args else newArgs

AnsiConsole.MarkupLine("")

let currentItems = continuationItems |> Option.defaultWith (fun () -> Collections.Generic.List())
currentItems.Add({ history with Args = args })

if promptForContinuation && not withLastArgs then
if AnsiConsole.Confirm("Do you want to select another history to continue?", defaultValue = false) then
match History.PromptSelect() with
| ValueSome item -> do! History.Run(ctx, item, continuationItems = currentItems, promptForContinuation = true)
| _ -> ()
AnsiConsole.MarkupLine("")

let currentItems = continuationItems |> Option.defaultWith (fun () -> Collections.Generic.List())
currentItems.Add({ history with Args = args })

if promptForContinuation && not withLastArgs then
if AnsiConsole.Confirm("Do you want to select another history to continue?", defaultValue = false) then
match History.PromptSelect() with
| ValueSome item -> do! History.Run(ctx, item, continuationItems = currentItems, promptForContinuation = true)
| _ -> ()
AnsiConsole.MarkupLine("")

// If there is no continuation commands need to fill, then we consider it should be executed now
if continuationItems.IsNone then
for index, history in Seq.indexed currentItems do
let scriptFile = Path.GetFileName history.Pipeline.Script
let scriptDir = Path.GetDirectoryName history.Pipeline.Script
let isHelpCommand = history.Args.Trim().ToLower() = "-h"

if not isHelpCommand then
History.Add { history with StartedTime = DateTime.Now }

if index = 0 then
AnsiConsole.Console.MarkupLine("[green]Start executing...[/]")
else
AnsiConsole.Console.MarkupLine("[green]Continue executing...[/]")
AnsiConsole.Console.WriteLine()

try
do!
ctx.RunCommand($"dotnet fsi \"{scriptFile}\" -- -p {history.Pipeline.Name} {history.Args}", workingDir = scriptDir)
|> Async.map (ignore >> Ok)
with _ ->
()

if currentItems.Count = 1 && isHelpCommand then do! History.Run(ctx, history)
}
// If there is no continuation commands need to fill, then we consider it should be executed now
if continuationItems.IsNone then
for index, history in Seq.indexed currentItems do
let scriptFile = Path.GetFileName history.Pipeline.Script
let scriptDir = Path.GetDirectoryName history.Pipeline.Script
let isHelpCommand = history.Args.Trim().ToLower() = "-h"

if not isHelpCommand then
History.Add { history with StartedTime = DateTime.Now }

if index = 0 then
AnsiConsole.Console.MarkupLine("[green]Start executing...[/]")
else
AnsiConsole.Console.MarkupLine("[green]Continue executing...[/]")
AnsiConsole.Console.WriteLine()

try
do!
ctx.RunCommand($"dotnet fsi \"{scriptFile}\" -- -p {history.Pipeline.Name} {history.Args}", workingDir = scriptDir)
|> Async.map (ignore >> Ok)
with _ ->
()

if currentItems.Count = 1 && isHelpCommand then do! History.Run(ctx, history)
}
110 changes: 54 additions & 56 deletions Fun.Build.Cli/Pipeline.fs
Original file line number Diff line number Diff line change
Expand Up @@ -157,68 +157,66 @@ type Pipeline with
pipeline: Pipeline,
?promptForContinuation: bool,
?continuationCommands: Collections.Generic.List<{| Pipeline: Pipeline; Args: string |}>
) =
asyncResult {
let promtForContinuation = defaultArg promptForContinuation false
let scriptFile = Path.GetFileName pipeline.Script
let scriptDir = Path.GetDirectoryName pipeline.Script
) = asyncResult {
let promtForContinuation = defaultArg promptForContinuation false
let scriptFile = Path.GetFileName pipeline.Script
let scriptDir = Path.GetDirectoryName pipeline.Script

let table = Table()
table.ShowHeaders <- false
table.AddColumns("", "") |> ignore
table.AddRow("Script", $"[green]{scriptFile}[/]") |> ignore
table.AddRow("Pipeline", $"[bold green]{pipeline.Name}[/]") |> ignore
table.AddRow("WorkingDir", $"[green]{scriptDir}[/]") |> ignore
if String.IsNullOrEmpty(pipeline.Description.Trim()) |> not then
table.AddRow("Description", $"[green]{pipeline.Description}[/]") |> ignore
let table = Table()
table.ShowHeaders <- false
table.AddColumns("", "") |> ignore
table.AddRow("Script", $"[green]{scriptFile}[/]") |> ignore
table.AddRow("Pipeline", $"[bold green]{pipeline.Name}[/]") |> ignore
table.AddRow("WorkingDir", $"[green]{scriptDir}[/]") |> ignore
if String.IsNullOrEmpty(pipeline.Description.Trim()) |> not then
table.AddRow("Description", $"[green]{pipeline.Description}[/]") |> ignore

AnsiConsole.Write table
AnsiConsole.Write table

let textPrompt = TextPrompt<string>("Arguments (-h for help): ")
textPrompt.AllowEmpty <- true
let args = AnsiConsole.Prompt textPrompt
let textPrompt = TextPrompt<string>("Arguments (-h for help): ")
textPrompt.AllowEmpty <- true
let args = AnsiConsole.Prompt textPrompt


let currentCommands = continuationCommands |> Option.defaultWith (fun () -> Collections.Generic.List())
currentCommands.Add({| Pipeline = pipeline; Args = args |})
let currentCommands = continuationCommands |> Option.defaultWith (fun () -> Collections.Generic.List())
currentCommands.Add({| Pipeline = pipeline; Args = args |})


AnsiConsole.MarkupLine("")

if promtForContinuation then
if AnsiConsole.Confirm("Do you want to select another pipeline to continue?", defaultValue = false) then
match Pipeline.PromptSelect() with
| ValueSome item -> do! Pipeline.Run(ctx, item, continuationCommands = currentCommands, promptForContinuation = true)
| _ -> ()
AnsiConsole.MarkupLine("")

if promtForContinuation then
if AnsiConsole.Confirm("Do you want to select another pipeline to continue?", defaultValue = false) then
match Pipeline.PromptSelect() with
| ValueSome item -> do! Pipeline.Run(ctx, item, continuationCommands = currentCommands, promptForContinuation = true)
| _ -> ()
AnsiConsole.MarkupLine("")

if continuationCommands.IsNone then
for index, command in Seq.indexed currentCommands do
let scriptFile = Path.GetFileName command.Pipeline.Script
let scriptDir = Path.GetDirectoryName command.Pipeline.Script
let isHelpCommand = command.Args.Trim().ToLower() = "-h"

if not isHelpCommand then
History.Add
{
Pipeline = pipeline
Args = args
StartedTime = DateTime.Now
}

if index = 0 then
AnsiConsole.Console.MarkupLine("[green]Start executing...[/]")
else
AnsiConsole.Console.MarkupLine("[green]Continue executing...[/]")
AnsiConsole.Console.WriteLine()

try
do!
ctx.RunCommand($"dotnet fsi \"{scriptFile}\" -- -p {command.Pipeline.Name} {command.Args}", workingDir = scriptDir)
|> Async.map (ignore >> Ok)
with _ ->
()

if isHelpCommand && currentCommands.Count = 1 then
do! Pipeline.Run(ctx, pipeline)
}
if continuationCommands.IsNone then
for index, command in Seq.indexed currentCommands do
let scriptFile = Path.GetFileName command.Pipeline.Script
let scriptDir = Path.GetDirectoryName command.Pipeline.Script
let isHelpCommand = command.Args.Trim().ToLower() = "-h"

if not isHelpCommand then
History.Add {
Pipeline = pipeline
Args = args
StartedTime = DateTime.Now
}

if index = 0 then
AnsiConsole.Console.MarkupLine("[green]Start executing...[/]")
else
AnsiConsole.Console.MarkupLine("[green]Continue executing...[/]")
AnsiConsole.Console.WriteLine()

try
do!
ctx.RunCommand($"dotnet fsi \"{scriptFile}\" -- -p {command.Pipeline.Name} {command.Args}", workingDir = scriptDir)
|> Async.map (ignore >> Ok)
with _ ->
()

if isHelpCommand && currentCommands.Count = 1 then
do! Pipeline.Run(ctx, pipeline)
}
Loading
Loading