Fix #235
This commit is contained in:
parent
2031dbdc71
commit
0f7727e31b
|
@ -122,14 +122,18 @@ EC getConfigFor(EC)(string path)
|
||||||
{
|
{
|
||||||
import std.stdio : File;
|
import std.stdio : File;
|
||||||
import std.regex : regex, match;
|
import std.regex : regex, match;
|
||||||
import std.path : globMatch, dirName, baseName, pathSplitter, buildPath;
|
import std.path : globMatch, dirName, baseName, pathSplitter, buildPath,
|
||||||
|
absolutePath;
|
||||||
import std.algorithm : reverse, map, filter;
|
import std.algorithm : reverse, map, filter;
|
||||||
import std.array : array;
|
import std.array : array;
|
||||||
|
import std.file : isDir;
|
||||||
|
|
||||||
EC result;
|
EC result;
|
||||||
EC[][] configs;
|
EC[][] configs;
|
||||||
string dir = dirName(path);
|
immutable expanded = absolutePath(path);
|
||||||
immutable string fileName = baseName(path);
|
immutable bool id = isDir(expanded);
|
||||||
|
immutable string dir = dirName(expanded);
|
||||||
|
immutable string fileName = id ? "dummy.d" : baseName(expanded);
|
||||||
string[] pathParts = cast(string[]) pathSplitter(dir).array();
|
string[] pathParts = cast(string[]) pathSplitter(dir).array();
|
||||||
for (size_t i = pathParts.length; i > 1; i--)
|
for (size_t i = pathParts.length; i > 1; i--)
|
||||||
{
|
{
|
||||||
|
|
|
@ -104,16 +104,6 @@ else
|
||||||
|
|
||||||
args.popFront();
|
args.popFront();
|
||||||
immutable bool readFromStdin = args.length == 0;
|
immutable bool readFromStdin = args.length == 0;
|
||||||
immutable string filePath = createFilePath(readFromStdin, readFromStdin ? null : args[0]);
|
|
||||||
Config config;
|
|
||||||
config.initializeWithDefaults();
|
|
||||||
Config fileConfig = getConfigFor!Config(filePath);
|
|
||||||
fileConfig.pattern = "*.d";
|
|
||||||
config.merge(fileConfig, filePath);
|
|
||||||
config.merge(optConfig, filePath);
|
|
||||||
|
|
||||||
if (!config.isValid())
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
File output = stdout;
|
File output = stdout;
|
||||||
version (Windows)
|
version (Windows)
|
||||||
|
@ -138,6 +128,11 @@ else
|
||||||
|
|
||||||
if (readFromStdin)
|
if (readFromStdin)
|
||||||
{
|
{
|
||||||
|
Config config;
|
||||||
|
config.initializeWithDefaults();
|
||||||
|
config.merge(optConfig, null);
|
||||||
|
if (!config.isValid())
|
||||||
|
return 1;
|
||||||
ubyte[4096] inputBuffer;
|
ubyte[4096] inputBuffer;
|
||||||
ubyte[] b;
|
ubyte[] b;
|
||||||
while (true)
|
while (true)
|
||||||
|
@ -164,11 +159,17 @@ else
|
||||||
{
|
{
|
||||||
inplace = true;
|
inplace = true;
|
||||||
foreach (string name; dirEntries(path, "*.d", SpanMode.depth))
|
foreach (string name; dirEntries(path, "*.d", SpanMode.depth))
|
||||||
{
|
|
||||||
args ~= name;
|
args ~= name;
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Config config;
|
||||||
|
config.initializeWithDefaults();
|
||||||
|
Config fileConfig = getConfigFor!Config(path);
|
||||||
|
fileConfig.pattern = "*.d";
|
||||||
|
config.merge(fileConfig, path);
|
||||||
|
config.merge(optConfig, path);
|
||||||
|
if (!config.isValid())
|
||||||
|
return 1;
|
||||||
File f = File(path);
|
File f = File(path);
|
||||||
buffer = new ubyte[](cast(size_t) f.size);
|
buffer = new ubyte[](cast(size_t) f.size);
|
||||||
f.rawRead(buffer);
|
f.rawRead(buffer);
|
||||||
|
@ -223,7 +224,8 @@ Formatting Options:
|
||||||
--split_operator_at_line_end
|
--split_operator_at_line_end
|
||||||
--compact_labeled_statements
|
--compact_labeled_statements
|
||||||
--template_constraint_style
|
--template_constraint_style
|
||||||
`, optionsToString!(typeof(Config.dfmt_template_constraint_style))());
|
`,
|
||||||
|
optionsToString!(typeof(Config.dfmt_template_constraint_style))());
|
||||||
}
|
}
|
||||||
|
|
||||||
private string createFilePath(bool readFromStdin, string fileName)
|
private string createFilePath(bool readFromStdin, string fileName)
|
||||||
|
|
Loading…
Reference in New Issue