diff options
author | Leo Kettmeir <crowlkats@toaxl.com> | 2024-08-21 06:54:59 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-21 06:54:59 -0700 |
commit | 71393370832946a33e8a34d2e9cfaad8bf97c91b (patch) | |
tree | 4fbb1c8ad9e2c734986611c43063b09aa38c1569 /cli/tools/task.rs | |
parent | e920835417d10f3735645c910e513886cdda6a39 (diff) |
feat(flags): improve help output and make `deno run` list tasks (#25108)
- rewrite flag help
- use gray for indentation
- reorganize permission flags and split them up
- make help subcommand act like help flag
- `deno run` outputs list of tasks
- Fixes #25120
error handling for `deno run` in case of no config file being found
needs to be improved
---------
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/tools/task.rs')
-rw-r--r-- | cli/tools/task.rs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/cli/tools/task.rs b/cli/tools/task.rs index 0110d1741..23da5b4fb 100644 --- a/cli/tools/task.rs +++ b/cli/tools/task.rs @@ -29,13 +29,24 @@ use std::sync::Arc; pub async fn execute_script( flags: Arc<Flags>, task_flags: TaskFlags, - using_run: bool, ) -> Result<i32, AnyError> { let factory = CliFactory::from_flags(flags); let cli_options = factory.cli_options()?; let start_dir = &cli_options.start_dir; if !start_dir.has_deno_or_pkg_json() { - bail!("deno task couldn't find deno.json(c). See https://docs.deno.com/go/config") + if task_flags.is_run { + bail!( + r#"deno run couldn't find deno.json(c). +If you meant to run a script, specify it, e.g., `deno run ./script.ts`. +To run a task, ensure the config file exists. +Examples: +- Script: `deno run ./script.ts` +- Task: `deno run dev` +See https://docs.deno.com/go/config"# + ) + } else { + bail!("deno task couldn't find deno.json(c). See https://docs.deno.com/go/config") + } } let force_use_pkg_json = std::env::var_os(crate::task_runner::USE_PKG_JSON_HIDDEN_ENV_VAR_NAME) @@ -142,7 +153,7 @@ pub async fn execute_script( } }, None => { - if using_run { + if task_flags.is_run { return Err(anyhow!("Task not found: {}", task_name)); } log::error!("Task not found: {}", task_name); |