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

feat: Add Interactive mode with target selection #1437

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

Danielku15
Copy link
Contributor

I confirm that the pull-request:

  • Follows the contribution guidelines
  • Is based on my own work
  • Is in compliance with my employer

This PR contains a proposal how #1436 could be implemented. Structurally we should still discuss where what should go but it already gives a feeling on what a user gets with this change.

Current design decisions

  • I opted to the SpecterConsole as proposed in the issue.
  • I moved the InvokedTarget loading logic into the ExecutableTargetFactory
  • I put the implementation of selecting targets into NukeBuild to allow people overriding and customizing it.
  • I made the ExecutableTargets public so custom implementations can use it.
  • For the sake of simplicity i did not move yet the console logic into the Terminal class.
  • I tried to keep the target selection output close to what a user sees when executing --help

Any feedback is welcome to complete this change.

Demo

rider64_xcwuHlW2Dh.mp4
class Build : NukeBuild
{
    public static int Main() => Execute<Build>();

    public Build()
    {
        Interactive = true;
    }

    public Target Compile => t => t
        .Description("Compiles the project")
        .Executes(() => Log.Information("Compile target execute"));

    public Target Test => t => t
        .DependsOn(Compile)
        .Description("Executes all tests")
        .Executes(() => Log.Information("Test target execute"));

    public Target PrepareEnvironment => t => t
        .Before(Compile)
        .Description("Prepares your development environment with all dependencies.")
        .Executes(() => Log.Information("PrepareEnvironment target execute"));
}

@@ -19,7 +19,7 @@ public interface INukeBuild
{
void ReportSummary(Configure<Dictionary<string, string>> configurator = null);

internal IReadOnlyCollection<ExecutableTarget> ExecutableTargets { get; }
IReadOnlyCollection<ExecutableTarget> ExecutableTargets { get; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be reverted

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my side this change was intentional. To properly be able to override and customize OnNoTargetsSpecified() developers need access to the general list of targets which are there as option.

e.g. in some projects we'd like to only be able to have a "single target" selection as this fits the project setup better and would like to change the default "multi selection" implementation shipped in nuke.

As alternative I could pass the executableTargets a parameter to OnNoTargetsSpecified.

@matkoch matkoch force-pushed the develop branch 2 times, most recently from 1131d5a to dc902f8 Compare November 5, 2024 09:00
@ITaluone
Copy link
Contributor

ITaluone commented Nov 8, 2024

I wouldn't go for "automatically detect local terminal and execute the interactive mode when no parameters given".

I would rather add an option on nuke :setup as opt-in. Maybe not everyone wants to be forced into interactive mode, especially, when running .\build.cmd before runs the pipeline and suddenly it stays in interactive mode, waiting for user input.
(Can also be considered as a behavioral breaking change IMHO)

@Danielku15
Copy link
Contributor Author

I wouldn't go for "automatically detect local terminal and execute the interactive mode when no parameters given".

@ITaluone I agree and there are some considerations around that in the proposal. One important detail in this implementation is: there is an additional --interactive parameter (or bool Interactive {get;set;}) which is default unset. With the current implementation you have following options as a developer/user:

  • You set --interactive on the commandline to activate the mode.
  • You can set this.Interactive = <your own check> in the constructor of your Build class to control things.
  • You can override the OnNoTargetsSpecified method and trigger any custom logic.

@matkoch matkoch force-pushed the develop branch 2 times, most recently from df620ac to 482f5ac Compare November 26, 2024 01:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants