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

D codecov Dub downloads Dub downloads License Latest version

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
  • https://dlang.org/spec/module.html
  • https://libdparse.dlang.io/grammar.html#importDeclaration
Authors:
  • karita
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
Show all 5 versions
Download Stats:
  • 0 downloads today

  • 2 downloads this week

  • 2 downloads this month

  • 2 downloads total

Score:
0.7
Short URL:
d-import-sort.dub.pm