A command to remove indentations in multiline strings
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 40.5k
- Forks
- 2.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 85
Description
Related problem
Embedded code is written in multiline strings.
def main [name: string] {
$'
.($name)-class-1 {
color: red;
}
.($name)-class-2 {
color: blue;
}
' | save $"($name).scss"
}
Once it's saved to a file (or, say, piped into an interpreter), indents persist, making code somewhat less readable. Not a problem if the created file is temporary, but it's something to be considered if the generated code is persistent and checked into the repo.
.pkg2-class-1 {
color: red;
}
.pkg2-class-2 {
color: blue;
}
.pkg2-class-3 {
color: green;
}
.pkg2-class-4 {
color: aquamarine;
}
Same goes for CSV and so on.
This is not good for scripts that write code to a file, which is frequent on a CI.
Describe the solution you'd like
A way (possibly a str unindent subcommand) to remove the indentation, similar to Kotlin's trimIndent.
Describe alternatives you've considered
Do not indent the code. This makes code less readable IMO, especially if there's multi level nesting (all nu code's on the right, and embedded code is suddenly all to the left).
def main [name: string] {
$'
.($name)-class-1 {
color: red;
}
.($name)-class-2 {
color: blue;
}
.($name)-class-3 {
color: green;
}
.($name)-class-4 {
color: aquamarine;
}
' | save $"($name).scss"
}
Additional context and details
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files or tests are named in the issue. Start by locating the existing string subcommands and their tests, then examine how multiline strings are represented and piped. Done means a documented command removes common indentation from examples like the embedded CSS, with tests covering blank lines and varying indentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100