shfmt - support simplifying (`-s`) and minifying flags (`-mn`)

Open
#2,032 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
shell
Domain
tooling

Research direction

Start at the existing shfmt Gradle DSL entry point and inspect how formatter options are exposed elsewhere, especially the ktfmt configuration pattern mentioned in the issue. Decide between configurable properties and fluent methods, then verify that simplify and minify can be enabled independently while minify implies simplify.

Written by the indexing model from the issue text.

Description

enhancement

shfmt supports simplifying and/or minifying shell scripts. However, there is no support provided via .editorconfig for the flags. So we'll need some additional configuration in the shfmt Gradle DSL to enable these.

My thoughts are something akin to one of the following:

Option 1

// Provides future extensible flexibility and follows the lead set by the `ktfmt` configuration
spotless {
  shell {
    shfmt().configure {
      it.minify = true
      it.simplify = true
    }
  }
}

Option 2

// If any other options become available in the future, this seems to be less extensible, however, it is very readable
spotless {
  shell {
    shfmt()
      .minify()
      .simplify()
  }
}

Note that minifying the code implies simplifying the code. So both flags can probably be true, but both flags aren't required to simplify and minify.

Dominant language
Java
Stars
5.7k
Forks
560
Avg merge
1d 13h
Merged PRs (30d)
43

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from diffplug/spotless

All issues in diffplug/spotless

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.