Browse Source

Require explicit - for stdin/stdout usage.

pull/19/head
Fredrik Ekre 1 year ago
parent
commit
d70a2fdef1
No known key found for this signature in database
GPG Key ID: DE82E6D5E364C0A2
  1. 14
      src/main.jl

14
src/main.jl

@ -44,7 +44,7 @@ function print_help() @@ -44,7 +44,7 @@ function print_help()
<path>...
Input path(s) (files and/or directories) to process. For directories,
all files (recursively) with the '*.jl' suffix are used as input files.
If no path is given, or if path is `-`, input is read from stdin.
If path is `-` input is read from stdin.
-c, --check
Do not write output and exit with a non-zero code if the input is not
@ -62,9 +62,9 @@ function print_help() @@ -62,9 +62,9 @@ function print_help()
paths.
-o, --output <file>
Output file to write formatted code to. If no output file is given, or
if the specified file is `-`, output is written to stdout. This option
can not be used together with multiple input paths.
Output file to write formatted code to. If the specified file is `-`
output is written to stdout. This option can not be used together with
multiple input paths.
""")
return
end
@ -150,7 +150,7 @@ function main(argv) @@ -150,7 +150,7 @@ function main(argv)
# stdin is the default input
if isempty(inputfiles)
push!(inputfiles, "-")
return panic("no input files or directories specified")
end
# multiple files require --inplace or --check and no --output
@ -220,7 +220,9 @@ function main(argv) @@ -220,7 +220,9 @@ function main(argv)
output = devnull
else
@assert length(inputfiles) == 1
if outputfile === nothing || outputfile == "-"
if outputfile === nothing
return panic("no output file specified")
elseif outputfile == "-"
output = stdout
elseif isfile(outputfile) && input_is_file && samefile(outputfile, inputfile)
return panic("can not use same file for input and output, use `-i` to modify a file in place")

Loading…
Cancel
Save