summaryrefslogtreecommitdiff
path: root/cli/main.rs
diff options
context:
space:
mode:
authorLeo Kettmeir <crowlkats@toaxl.com>2024-08-21 06:54:59 -0700
committerGitHub <noreply@github.com>2024-08-21 06:54:59 -0700
commit71393370832946a33e8a34d2e9cfaad8bf97c91b (patch)
tree4fbb1c8ad9e2c734986611c43063b09aa38c1569 /cli/main.rs
parente920835417d10f3735645c910e513886cdda6a39 (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/main.rs')
-rw-r--r--cli/main.rs21
1 files changed, 18 insertions, 3 deletions
diff --git a/cli/main.rs b/cli/main.rs
index 6a7575dee..290eee120 100644
--- a/cli/main.rs
+++ b/cli/main.rs
@@ -218,9 +218,10 @@ async fn run_subcommand(flags: Arc<Flags>) -> Result<i32, AnyError> {
let task_flags = TaskFlags {
cwd: None,
task: Some(run_flags.script.clone()),
+ is_run: true,
};
new_flags.subcommand = DenoSubcommand::Task(task_flags.clone());
- let result = tools::task::execute_script(Arc::new(new_flags), task_flags.clone(), true).await;
+ let result = tools::task::execute_script(Arc::new(new_flags), task_flags.clone()).await;
match result {
Ok(v) => Ok(v),
Err(_) => {
@@ -240,7 +241,7 @@ async fn run_subcommand(flags: Arc<Flags>) -> Result<i32, AnyError> {
tools::serve::serve(flags, serve_flags).await
}),
DenoSubcommand::Task(task_flags) => spawn_subcommand(async {
- tools::task::execute_script(flags, task_flags, false).await
+ tools::task::execute_script(flags, task_flags).await
}),
DenoSubcommand::Test(test_flags) => {
spawn_subcommand(async {
@@ -290,7 +291,21 @@ async fn run_subcommand(flags: Arc<Flags>) -> Result<i32, AnyError> {
tools::registry::publish(flags, publish_flags).await
}),
DenoSubcommand::Help(help_flags) => spawn_subcommand(async move {
- display::write_to_stdout_ignore_sigpipe(help_flags.help.ansi().to_string().as_bytes())
+ use std::io::Write;
+
+ let mut stream = anstream::AutoStream::new(std::io::stdout(), if colors::use_color() {
+ anstream::ColorChoice::Auto
+ } else {
+ anstream::ColorChoice::Never
+ });
+
+ match stream.write_all(help_flags.help.ansi().to_string().as_bytes()) {
+ Ok(()) => Ok(()),
+ Err(e) => match e.kind() {
+ std::io::ErrorKind::BrokenPipe => Ok(()),
+ _ => Err(e),
+ },
+ }
}),
};