Skip to content

Commit

Permalink
Make fmt a workspace command
Browse files Browse the repository at this point in the history
  • Loading branch information
udoprog committed May 8, 2023
1 parent 9e2ba25 commit e410d9f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions crates/rune/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ use crate::modules::capture_io::CaptureIo;
use crate::termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
use crate::{Context, ContextError, Options, Hash};

/// Commands which by default should look in the workspace for entrypoints.
macro_rules! workspace_command {
() => {
Command::Check(..) | Command::Doc(..) | Command::Fmt(..)
}
}

/// Default about splash.
const DEFAULT_ABOUT: &str = "The Rune Language Interpreter";

Expand Down Expand Up @@ -290,7 +297,7 @@ impl Command {
fn find_bins(&self) -> Option<WorkspaceFilter<'_>> {
if !matches!(
self,
Command::Run(..) | Command::Check(..) | Command::Doc(..)
Command::Run(..) | workspace_command!()
) {
return None;
}
Expand All @@ -307,7 +314,7 @@ impl Command {
fn find_tests(&self) -> Option<WorkspaceFilter<'_>> {
if !matches!(
self,
Command::Test(..) | Command::Check(..) | Command::Doc(..)
Command::Test(..) | workspace_command!()
) {
return None;
}
Expand All @@ -324,7 +331,7 @@ impl Command {
fn find_examples(&self) -> Option<WorkspaceFilter<'_>> {
if !matches!(
self,
Command::Run(..) | Command::Check(..) | Command::Doc(..)
Command::Run(..) | workspace_command!()
) {
return None;
}
Expand All @@ -341,7 +348,7 @@ impl Command {
fn find_benches(&self) -> Option<WorkspaceFilter<'_>> {
if !matches!(
self,
Command::Bench(..) | Command::Check(..) | Command::Doc(..)
Command::Bench(..) | workspace_command!()
) {
return None;
}
Expand Down

0 comments on commit e410d9f

Please sign in to comment.