importsort-d

Sort and format imports in DLang
Log | Files | Refs | README

commit 678425f35dfc8a44d1a74a36dc20dbed688cd1d8
parent 3171199b5fc37431d7048ac2ea57b7649d217271
Author: Friedel Schön <[email protected]>
Date:   Tue, 11 Oct 2022 11:42:01 +0200

add error message on file_not_found

Diffstat:
Msrc/main.d | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/main.d b/src/main.d @@ -5,7 +5,7 @@ module importsort; import core.stdc.stdlib : exit; import std.algorithm : findSplit, map, sort; import std.array : array; -import std.file : rename; +import std.file : exists, isFile, rename; import std.regex : ctRegex, matchFirst; import std.stdio : File, stderr, stdin, stdout; import std.string : format, indexOf, split, strip, stripLeft; @@ -225,11 +225,13 @@ void main(string[] args) { } File infile, outfile; - if (inline) { - infile = File(path); - } else if (path == "-") { + if (path == "-") { infile = stdin; } else { + if (!path.exists() || !path.isFile()) { + stderr.writef("error: file '%s' does not exist or is not a file.\n", path); + exit(1); + } infile = File(path); }