keep-sorted
keep-sorted copied to clipboard
Feature Request: skip_last_lines (in addition to skip_lines=x)
When running keep-sorted in our ruby code base, we have the following syntax that wraps arrays
# keep-sorted start
SOME_ARRAY = %w[
AAA
BBB
CCC
].freeze
# keep-sorted end
We are unable to nest the # keep-sorted start/end within the array because of the %w. E.g. this is incorrect
SOME_ARRAY = %w[
# keep-sorted start
AAA
BBB
CCC
# keep-sorted end
].freeze
What we're doing as somewhat of a workaround, which we believe is effectively sorting the last row ].freeze as well (which would be incorrect)
# keep-sorted start skip_lines=1 block=yes
SOME_ARRAY = %w[
AAA
BBB
CCC
].freeze
# keep-sorted end
The feature request is to add a syntax that allows something like this:
# keep-sorted start skip_lines=1 skip_last_lines=1 block=yes
SOME_ARRAY = %w[
AAA
BBB
CCC
].freeze
# keep-sorted end
I like the idea! I'd generally like to avoid adding one-off options for everything though. A couple thoughts
- Is there some other array creation syntax in ruby that would let you nest the keep-sorted directives inside the braces?
- I wonder if this could perhaps just be part of the same
skip_linesoption, except we use negative numbers to indicate an offset from the end statement.skip_lines=1,-1