From 71393370832946a33e8a34d2e9cfaad8bf97c91b Mon Sep 17 00:00:00 2001 From: Leo Kettmeir Date: Wed, 21 Aug 2024 06:54:59 -0700 Subject: feat(flags): improve help output and make `deno run` list tasks (#25108) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- cli/tools/task.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'cli/tools/task.rs') 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, task_flags: TaskFlags, - using_run: bool, ) -> Result { 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); -- cgit v1.2.3