d-import-sort 0.0.4
A D script for sorting import statements.
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
d-import-sort
A tool for sorting import declarations in D.
Usage
$ dub fetch d-import-sort
$ dub run d-import-sort <files>
<<<<filename:minline-maxline
unsorted imports
...
----
sorted imports
...
>>>>
...
Example
$ dub run -- ./source/*.d
<<<<./source/app.d:2-5
import std.string : empty;
import std.stdio : writeln;
import std.file : readText;
----
import std.file : readText;
import std.stdio : writeln;
import std.string : empty;
>>>>
<<<<./source/dimportsort.d:89-92
import std.algorithm : find;
import std.range : drop, take;
import std.algorithm : maxElement, minElement, joiner, splitter;
----
import std.algorithm : find, joiner, maxElement, minElement, splitter;
import std.range : drop, take;
>>>>
TODO
- [x] fully support import declarations
- [x] single import e.g.
import foo;
- [x] multiple import e.g.
import foo, bar;
- [x] selective import e.g.
import foo : bar;
- [x] public import e.g.
public import foo;
- [x] static import e.g.
static import foo;
- [x] package attribute e.g.
package(app) import foo;
. - [x] renamed import e.g.
import foo = bar;
- [x] simple sorted output
- [x] merge imports for redundant modules
- [ ] option for overwriting files
- [ ] option for keeping comments
- [ ] color output
- [ ]
diff
format output - [ ] max line length
Links
- https://dlang.org/spec/module.html
- https://libdparse.dlang.io/grammar.html#importDeclaration
- Registered by shigeki karita
- 0.0.4 released 3 years ago
- ShigekiKarita/d-import-sort
- BSL-1.0
- Copyright © 2021, karita
- Authors:
- Dependencies:
- libdparse
- Versions:
-
0.0.4 2021-Nov-23 0.0.3 2021-Nov-23 0.0.2 2021-Nov-22 0.0.1 2021-Nov-22 ~master 2021-Nov-23 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
9 downloads total
-
- Score:
- 0.9
- Short URL:
- d-import-sort.dub.pm