Skip to content

Commit 9dd7f70

Browse files
committed
Using itfmt without arguments now formats from stdin and prints to stdout.
1 parent f31a2ed commit 9dd7f70

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ITensorFormatter"
22
uuid = "b6bf39f1-c9d3-4bad-aad8-593d802f65fd"
3-
version = "0.2.28"
3+
version = "0.3.0"
44
authors = ["ITensor developers <support@itensor.org> and contributors"]
55

66
[workspace]

src/main.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,25 @@ function process_args(argv)
143143
return (; paths, format, format_yaml)
144144
end
145145

146+
function format_stdin()
147+
content = read(stdin, String)
148+
content = organize_import_blocks_string(content)
149+
content = JuliaFormatter.format_text(content; JULIAFORMATTER_OPTIONS...)
150+
content = Runic.format_string(content)
151+
write(stdout, content)
152+
return 0
153+
end
154+
146155
"""
147156
$(help_markdown())
148157
"""
149158
function main(argv)
150159
(; paths, format, format_yaml) = process_args(argv)
151160
!format && return 0
152-
isempty(paths) && return error("No input paths provided.")
161+
if isempty(paths)
162+
format_stdin()
163+
return 0
164+
end
153165
jlfiles = filterpaths(isjlfile, paths)
154166
yamlfiles = format_yaml ? filterpaths(isyamlfile, paths) : String[]
155167
projectomls = filterpaths(isprojecttoml, paths)

0 commit comments

Comments
 (0)