mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 21:44:16 +00:00
build_tools/style.fish: Use black as python formatter
(Also renames the silly "$f_files" to "$fish_files")
This commit is contained in:
parent
3bea947bb5
commit
2b3f48d9ee
1 changed files with 22 additions and 5 deletions
|
@ -5,7 +5,8 @@
|
||||||
#
|
#
|
||||||
set git_clang_format no
|
set git_clang_format no
|
||||||
set c_files
|
set c_files
|
||||||
set f_files
|
set fish_files
|
||||||
|
set python_files
|
||||||
set all no
|
set all no
|
||||||
|
|
||||||
if test "$argv[1]" = "--all"
|
if test "$argv[1]" = "--all"
|
||||||
|
@ -30,7 +31,8 @@ if test $all = yes
|
||||||
# For now we don't restyle all fish scripts other than completion scripts. That's because people
|
# For now we don't restyle all fish scripts other than completion scripts. That's because people
|
||||||
# really like to vertically align the elements of the `complete` command and fish_indent
|
# really like to vertically align the elements of the `complete` command and fish_indent
|
||||||
# currently does not honor that whitespace.
|
# currently does not honor that whitespace.
|
||||||
set f_files (printf '%s\n' share/***.fish | grep -v /completions/)
|
set fish_files (printf '%s\n' share/***.fish | grep -v /completions/)
|
||||||
|
set python_files **.py
|
||||||
else
|
else
|
||||||
# We haven't been asked to reformat all the source. If there are uncommitted changes reformat
|
# We haven't been asked to reformat all the source. If there are uncommitted changes reformat
|
||||||
# those using `git clang-format`. Else reformat the files in the most recent commit.
|
# those using `git clang-format`. Else reformat the files in the most recent commit.
|
||||||
|
@ -49,7 +51,8 @@ else
|
||||||
test -f $file; and set c_files $c_files $file
|
test -f $file; and set c_files $c_files $file
|
||||||
end
|
end
|
||||||
# Extract just the fish files.
|
# Extract just the fish files.
|
||||||
set f_files (string match -r '^.*\.fish$' -- $files)
|
set fish_files (string match -r '^.*\.fish$' -- $files)
|
||||||
|
set python_files (string match -r '^.*\.py$' -- $files)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Run the C++ reformatter if we have any C++ files.
|
# Run the C++ reformatter if we have any C++ files.
|
||||||
|
@ -90,7 +93,7 @@ if set -q c_files[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Run the fish reformatter if we have any fish files.
|
# Run the fish reformatter if we have any fish files.
|
||||||
if set -q f_files[1]
|
if set -q fish_files[1]
|
||||||
if not type -q fish_indent
|
if not type -q fish_indent
|
||||||
make fish_indent
|
make fish_indent
|
||||||
set PATH . $PATH
|
set PATH . $PATH
|
||||||
|
@ -99,7 +102,7 @@ if set -q f_files[1]
|
||||||
echo ========================================
|
echo ========================================
|
||||||
echo Running fish_indent
|
echo Running fish_indent
|
||||||
echo ========================================
|
echo ========================================
|
||||||
for file in $f_files
|
for file in $fish_files
|
||||||
cp $file $file.new # preserves mode bits
|
cp $file $file.new # preserves mode bits
|
||||||
fish_indent <$file >$file.new
|
fish_indent <$file >$file.new
|
||||||
if cmp --quiet $file $file.new
|
if cmp --quiet $file $file.new
|
||||||
|
@ -110,3 +113,17 @@ if set -q f_files[1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if set -q python_files[1]
|
||||||
|
if not type -q black
|
||||||
|
echo
|
||||||
|
echo Please install "`black`" to style python
|
||||||
|
echo
|
||||||
|
else
|
||||||
|
echo
|
||||||
|
echo ========================================
|
||||||
|
echo Running black
|
||||||
|
echo ========================================
|
||||||
|
black $python_files
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in a new issue