mirror of
https://github.com/RGBCube/alejandra
synced 2025-07-30 12:07:46 +00:00
feat: respect - for stdin
This commit is contained in:
parent
8f724a92c4
commit
36f44e93e3
2 changed files with 10 additions and 7 deletions
|
@ -17,20 +17,20 @@ const AFTER_HELP: &str = indoc::indoc! {"
|
|||
"
|
||||
};
|
||||
|
||||
/// The Uncompromising Nix Code Formatter
|
||||
/// The Uncompromising Nix Code Formatter.
|
||||
#[derive(Debug, Parser)]
|
||||
#[clap(version, after_help = AFTER_HELP, term_width = 80)]
|
||||
struct Args {
|
||||
/// Files or directories, or none to format stdin
|
||||
/// Files or directories, or a single "-" (or leave empty) to format stdin.
|
||||
#[clap(multiple_values = true)]
|
||||
include: Vec<String>,
|
||||
|
||||
/// Files or directories to exclude from formatting
|
||||
/// Files or directories to exclude from formatting.
|
||||
#[clap(long, short, multiple_occurrences = true)]
|
||||
exclude: Vec<String>,
|
||||
|
||||
/// Check if the input is already formatted and disable writing in-place
|
||||
/// the modified content
|
||||
/// the modified content.
|
||||
#[clap(long, short)]
|
||||
check: bool,
|
||||
|
||||
|
@ -334,8 +334,11 @@ pub fn main() -> std::io::Result<()> {
|
|||
.build_global()
|
||||
.unwrap();
|
||||
|
||||
let formatted_paths = match &args.include[..] {
|
||||
&[] => {
|
||||
let include: Vec<&str> =
|
||||
args.include.iter().map(String::as_str).collect::<Vec<&str>>();
|
||||
|
||||
let formatted_paths = match &include[..] {
|
||||
&[] | &["-"] => {
|
||||
vec![crate::cli::stdin(args.quiet)]
|
||||
}
|
||||
include => {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::collections::HashSet;
|
||||
|
||||
pub(crate) fn nix_files(include: &[String], exclude: &[String]) -> Vec<String> {
|
||||
pub(crate) fn nix_files(include: &[&str], exclude: &[String]) -> Vec<String> {
|
||||
let include: HashSet<_> =
|
||||
include.iter().flat_map(|s| nix_files_in_path(s)).collect();
|
||||
let exclude: HashSet<_> =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue