-
Notifications
You must be signed in to change notification settings - Fork 323
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
docs: Add more examples for toml tasks #3491
Conversation
docs/tasks/toml-tasks.md
Outdated
@@ -143,10 +141,60 @@ run = 'echo {{flag(name=("myflag")}}' | |||
# runs: echo true | |||
``` | |||
|
|||
```toml | |||
[tasks.maybeClean] | |||
run = """if [ '{{flag(name='clean')}}' = 'true' ]; then echo 'cleaning' ; fi""", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like a missed opportunity to show how multiline strings work in toml. The comma at the end is also a syntax error
docs/tasks/toml-tasks.md
Outdated
|
||
[tasks.download_task] | ||
description = "Shows that you can use deno in a task" | ||
shell = 'deno eval' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while this works, it can also be done with a shebang:
run = """
#!/usr/bin/env -S deno run --allow-env
"""
which I prefer even though users need to understand env -S
(which I don't see as a downside, env -S
is great). I think we should show both methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know this for sure, but I suspect a shebang would also be easier for IDEs to syntax highlight, so I think that should be our preferred method here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah wait, this is mise
parsing the script actually, so it should work on window then.
mise/src/task/task_script_parser.rs
Lines 312 to 314 in d5781be
let shell_type: Option<ShellType> = shell_from_shebang(script) | |
.or(task.shell()) | |
.unwrap_or(SETTINGS.default_inline_shell()?)[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that is only partially done, the shell_type there is only used for knowing whether or not it should escape args but I plan to soon make it actually parse and execute the shebang directly instead of going through sh -c
. I would still document it this way, the windows issue I'll fix soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if only I knew the mise-vscode maintainer ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do think syntax highlighting with shebangs would be a killer feature, or even if you got it to default to multiline strings as bash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw we should add your extension to the docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I will make a PR next week. Want to check the windows support first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be worth waiting until I get the shebang parsing fully in place—right now it almost certainly will fail with any shebang—though a user could work around that with run_windows
docs/tasks/toml-tasks.md
Outdated
shell = 'deno eval' # or use a shebang: #!/usr/bin/env -S deno run | ||
run = """ | ||
import ProgressBar from "jsr:@deno-library/progress"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, this is what I meant
shell = 'deno eval' # or use a shebang: #!/usr/bin/env -S deno run | |
run = """ | |
import ProgressBar from "jsr:@deno-library/progress"; | |
run = """ | |
#!/usr/bin/env -S deno run | |
import ProgressBar from "jsr:@deno-library/progress"; |
this is just a note, but there actually is a scenario where you may prefer [tasks.foo]
run = [
"""
#!/usr/bin/env node
console.log("node")
""",
"""
#!/usr/bin/env bash
echo "foo"
"""" but of course I don't think it's worth documenting this |
docs/tasks/toml-tasks.md
Outdated
|
||
[tasks.python_task] | ||
run = """ | ||
#!/usr/bin/env -S python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should reserve env -S
for shebangs that have multiple args (like deno run
). We should also document on this page what the heck env -S
does in a callout of some kind. I suspect most users won't have a clue what it means. I think I already do that in the tips and tricks doc but this page is going to be far more heavily trafficked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, I will update 👍
sorry for a bit of back and forth on this, but I think I know what I want to do in regards to documenting What we do need on this page though is an exhaustive list of all the properties you can pass to tasks like we have for settings. That's where |
the tricky thing about that list though is almost all properties are associated with file and toml tasks. So I'm not sure where it should live. |
I would document them in the toml task documentation. In the file task, given that there are a few examples already, we can just add a link indicating that the same properties are supported (https://mise.jdx.dev/tasks/file-tasks.html#arguments) |
one more thing, I've been using |
oh whoops, seems I am not using Line 375 in 224a0b5
I forgot about that. idk what this means for windows but it may work? probably not though |
Still had one commit to make 😅 |
|
||
## quiet | ||
|
||
Set `quiet = false` to supress mise additional output. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hverlin should this be quiet = true
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait I think I missed this, we don't actually have this lol, this was a feature idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe I'll just implement it so we don't need to remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in #3514
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, this is why I was asking in the discord
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other fixes: #3501
No description provided.