bau icon indicating copy to clipboard operation
bau copied to clipboard

Command line switch to display tasks

Open adamralph opened this issue 11 years ago • 17 comments
trafficstars

adamralph avatar Jun 02 '14 03:06 adamralph

This would allow tools like Scrawl for example to display a list of tasks that are available to be run from within the IDE.

aarondandy avatar Apr 15 '15 20:04 aarondandy

:+1:

stirno avatar Apr 15 '15 20:04 stirno

Yeah, this really needs to get done. I need to make a general push on Bau features soon. It hasn't had enough love for a while :stuck_out_tongue:

adamralph avatar Apr 16 '15 06:04 adamralph

Do you have any thoughts on how this would work?

scriptcs baufile.csx -- -list vs scriptcs baufile.csx -- task-name ?

What if I make a task named -list (not that I should)?

What about default tasks baked into Bau that can be overridden in a baufile to hide private tasks?

.Task("bau.list")
.MarkAsPrivateOrImplementationDetails()
.Do(() => {
    Console.WriteLine(ListOfPublicTasks());
    Environment.Exit(ExitCodes.ListSuccess);
});

Possibly related: https://github.com/scriptcs/scriptcs/issues/339

Makes me also wonder if a task should be marked as private or internal. I have a lot of tasks that simply make sure everything happens correctly or with proper ordering but I don't want people to invoke directly. Maybe another issue or you want to shoot that down here and now?

aarondandy avatar Apr 21 '15 18:04 aarondandy

My thoughts were to follow the precedents set by Rake and, to some extent, gulp:

scriptcs baufile.csx -- -T      # Display all tasks which have a description
scriptcs baufile.csx -- -A      # Display all tasks
scriptcs baufile.csx -- -P      # Display all tasks and their prerequisites

The idea of -T being that each task designed to be explicitly invokable should have some kind of description attached. Of course we would have to introduce the concept of task descriptions, e.g.

bau.MSBuild("build").Desc("Build solution").DependsOn(...).Do(...):

Bear in mind that the ultimate aim is for scriptcs to support command line packages, so there will eventually be a Bau.Cli NuGet package which installs bau as a global command, allowing:

bau -T
bau -A
bau -P

adamralph avatar Apr 21 '15 19:04 adamralph

I like the description approach much better and it should be easy to implement. Want to include the .Desc(description) stuff in this issue as it is pretty much required? -T and -A are stupid simple but what does -P look like?

aarondandy avatar Apr 21 '15 19:04 aarondandy

Descriptions are already covered in https://github.com/bau-build/bau/issues/65 so this issue is probably dependent on that. I guess both could be solved in one PR though.

rake -P gives something like this (for https://github.com/xbehave/xbehave.net):

rake accept
    build
rake artifacts
rake artifacts/logs
rake artifacts/output
rake build
    clean
    restore
    artifacts/logs
rake clean
    artifacts/logs
rake component
    build
rake default
    component
    accept
    pack
rake pack
    build
    artifacts/output
rake restore

adamralph avatar Apr 21 '15 19:04 adamralph

Currently Bau allows for whitespace in task names. The easy solution to this problem is to tell people "don't do that" but would it be better to wrap task names in quotes and do \ escaping if they contain whitespace or to restrict tasknames with whitespace? Escaping can be included in this task but restricting would need to be another item. Can this be ignored for now until somebody complains about it or would that be too reactionary?

aarondandy avatar Apr 21 '15 20:04 aarondandy

What is the problem with having whitespace in task names?

On 22:08, Tue, 21 Apr 2015 Aaron Dandy [email protected] wrote:

Currently Bau allows for whitespace in task names. The easy solution to this problem is to tell people "don't do that" but would it be better to wrap task names in quotes and do \ escaping if they contain whitespace or to restrict tasknames with whitespace? Escaping can be included in this task but restricting would need to be another item. Can this be ignored for now until somebody complains about it or would that be too reactionary?

— Reply to this email directly or view it on GitHub https://github.com/bau-build/bau/issues/166#issuecomment-94923051.

adamralph avatar Apr 22 '15 04:04 adamralph

I wonder if it could cause issues for others when parsing the output. As I think about it though I guess it would be more of an issue if there were a # in the task name than whitespace. Even then a parser should look for \s# and not just # on it's own. It should probably be ignored for now.

aarondandy avatar Apr 22 '15 04:04 aarondandy

By parsing you mean automated parsing?

adamralph avatar Apr 22 '15 04:04 adamralph

Yes.

aarondandy avatar Apr 22 '15 04:04 aarondandy

OK. So I think quote wrapping is probably the solution for that.

If we examine the current command line, Bau already supports the running of specific tasks like so:

> scriptcs baufile.csx -- build pack

In the case where a task has whitespace, the usual command line convention of quoting is used:

> scriptcs baufile.csx -- "build solution" pack

So I would expect the output to follow suit:

> scriptcs baufile.csx -- -T
"build solution"        # Builds the solution
pack                    # Creates the NuGet packages

I don't think # should cause any problems. If the output is as above, then the # which denotes the description is the first # which is prepended with whitespace outside a task name. A task name of the form a#b has no whitespace before the # and a task name of the form "a #b" is necessarily quoted so the parser knows the # is part of the name. It's true that this adds a little overhead to the parser implementation but we could also consider supporting some kind of serialized output specially for parsers. E.g.

> scriptcs baufile.csx -- -J
{
    tasks: [
        {
            name: "accept",
            description: "Run acceptance tests",
            dependencies: [
                "build"
            ]
        },
        {
            name: "build",
            description: "Build the solution",
            dependencies: [
                "clean",
                "restore"
            ]
        },
        ...
    ]
}

adamralph avatar Apr 22 '15 05:04 adamralph

big :+1: to JSON output! Thats how we did it for pvc using a fairly ridiculous command line argument that i'm not happy with but life is much easier with JSON :)

stirno avatar Apr 22 '15 17:04 stirno

My office will be moving on Friday and I think I will be kicked out of work. I want to see this implemented so I intend to take a shot at it :construction_worker: this weekend if I don't get sucked into Pillars of Eternity :feelsgood:.

aarondandy avatar Apr 22 '15 18:04 aarondandy

This has gone out in https://www.nuget.org/packages/Bau/0.1.0-beta09

adamralph avatar Jun 30 '15 21:06 adamralph

This should be changed to use standard colours, i.e. dark cyan for tasks. (Perhaps light cyan for the dependent task in the -P output.)

adamralph avatar Feb 28 '16 17:02 adamralph