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

add default task feature #16194

Closed
wants to merge 3 commits into from
Closed

Conversation

gutenfries
Copy link

feat(cli): Add default task behavior (#15241)

when deno task is run, this is the updated behavior;
for a deno.json file that looks like this:

{
  "tasks": {
    "boolean_logic": "sleep 0.1 && echo 3 && echo 4 & echo 1 && echo 2 || echo NOPE",
    "echo": "echo 1",
    "deno_echo": "deno eval 'console.log(5)'",
    "strings": "deno run main.ts && deno eval \"console.log(\\\"test\\\")\"",
    "piped": "echo 12345 | (deno eval 'const b = new Uint8Array(1);Deno.stdin.readSync(b);console.log(b)' && deno eval 'const b = new Uint8Array(1);Deno.stdin.readSync(b);console.log(b)')",
    "exit_code_5": "echo $(echo 10 ; exit 2) && exit 5",
    "echo_cwd": "echo $(pwd)",
    "default": "echo 1 && echo 2",
    "main": "echo \"~Main task~\""
  }
}

task 'main'
Command:

deno task main

Output:

Warning deno task is unstable and may drastically change in the future
~Main task~

no args
Command:

deno task

Output:

Warning deno task is unstable and may drastically change in the future
Warning No task specified; attempting to run a default task. To prevent this behavior, pass `--no-default-task`. Run `deno task --help` for more info.
Running default task: default
1
2

no args with --no-default-task
Command:

deno task --no-default-task

Output:

Warning deno task is unstable and may drastically change in the future
No task specified
Available tasks:
- boolean_logic
    sleep 0.1 && echo 3 && echo 4 & echo 1 && echo 2 || echo NOPE
- default
    echo 1 && echo 2
- deno_echo
    deno eval 'console.log(5)'
- echo
    echo 1
- echo_cwd
    echo $(pwd)
- exit_code_5
    echo $(echo 10 ; exit 2) && exit 5
- main
    echo "~Main task~"
- piped
    echo 12345 | (deno eval 'const b = new Uint8Array(1);Deno.stdin.readSync(b);console.log(b)' && deno eval 'const b = new Uint8Array(1);Deno.stdin.readSync(b);console.log(b)')
- strings
    deno run main.ts && deno eval "console.log(\"test\")"

Non-existent task
Command:

deno task dinosaur

Output:

Warning deno task is unstable and may drastically change in the future
Task not found: dinosaur
Available tasks:
- boolean_logic
    sleep 0.1 && echo 3 && echo 4 & echo 1 && echo 2 || echo NOPE
- default
    echo 1 && echo 2
- deno_echo
    deno eval 'console.log(5)'
- echo
    echo 1
- echo_cwd
    echo $(pwd)
- exit_code_5
    echo $(echo 10 ; exit 2) && exit 5
- main
    echo "~Main task~"
- piped
    echo 12345 | (deno eval 'const b = new Uint8Array(1);Deno.stdin.readSync(b);console.log(b)' && deno eval 'const b = new Uint8Array(1);Deno.stdin.readSync(b);console.log(b)')
- strings
    deno run main.ts && deno eval "console.log(\"test\")"

Edge cases concerning flag combinations, injection, etc were accounted for.

Please see line ~2677 in cli/args/flags.rs.
There is some temporary code that I added (in addition to the existing temporary code), but note that this will need to be changed when this code is updated in relationship to clap-rs/clap#1538

Let me know if there are issues or enhancements, or if there is any insight into the PR.

Thanks!

@CLAassistant
Copy link

CLAassistant commented Oct 7, 2022

CLA assistant check
All committers have signed the CLA.

@dsherret
Copy link
Member

dsherret commented Oct 7, 2022

Sorry you put the work in, but as mentioned in the issue, this hasn't been agreed upon. We will most likely not do this behaviour.

@gutenfries
Copy link
Author

okay, sounds good!

@dsherret
Copy link
Member

Again, sorry you worked on this, but it was never agreed upon in the issue to implement this behaviour. Going to close this one as it's not planned to do it.

@dsherret dsherret closed this Oct 22, 2022
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