Skip to content

Commit

Permalink
change indent size to 4 and remove backup file creation
Browse files Browse the repository at this point in the history
  • Loading branch information
R3tr0BoiDX committed Dec 14, 2024
1 parent b5e8453 commit 07ad10e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@
/.antlr
/scadformat
/scadformat.exe

go/*
go

venv
venv/*
go1.22.2.linux-amd64.tar.gz
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ SCADFormat is a source code formatter / beautifier for [OpenSCAD](https://opensc

SCADFormat is, shall we say, "opinionated" in the way that it formats OpenSCAD code. In other words, there are no configuration options that alter the way code is formatted. That's not because I feel strongly that OpenSCAD code should be formatted a certain way - it's just that I haven't had time to implement options.

## Installation
## Changes in this fork

The easiest way to install is to download one of the pre-built binary releases:
Compared to hugheaves/scadformat not much has changed. All I did was increase the indent size from 2 to 4, since that's also my personal preference as well as the VSCode extension I use has a hard time with 2 indents. Other than that, I also removed the creation of the backup file (files suffixed with a date and `.scadbak`), as my directory got cluttered with old backups quite quickly, even though I had no use for those files.

https://github.com/hugheaves/scadformat/releases
## Installation

Download the zip file for your operating system (windows.zip, linux,zip, macos.zip) and extract the contents.
The easiest way to install is to download one of the pre-built binary releases. I can only provide a Linux x64 build tho. Check out the release page for that.

## Usage

Expand Down
2 changes: 1 addition & 1 deletion internal/formatter/formatsettings.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ func DefaultFormatSettings(fileName string) *FormatSettings {
return &FormatSettings{
fileName: fileName,
maxLineLen: math.MaxInt,
indentSize: 2,
indentSize: 4,
}
}
17 changes: 7 additions & 10 deletions internal/formatter/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ import (
"fmt"
"io"
"os"
"path/filepath"
"strings"
"time"

"github.com/antlr4-go/antlr/v4"
"github.com/hugheaves/scadformat/internal/parser"
Expand Down Expand Up @@ -69,13 +66,13 @@ func (f *Formatter) formatFile() error {
return err
}

timeStamp := time.Now().Format("2006-01-02_15-04-05")
backupFileName := strings.TrimSuffix(f.settings.fileName, filepath.Ext(f.settings.fileName)) + "_" + timeStamp + ".scadbak"
err = os.WriteFile(backupFileName, input, 0666)
if err != nil {
zap.S().Errorf("failed to write file %s: %s", backupFileName, err)
return err
}
// timeStamp := time.Now().Format("2006-01-02_15-04-05")
// backupFileName := strings.TrimSuffix(f.settings.fileName, filepath.Ext(f.settings.fileName)) + "_" + timeStamp + ".scadbak"
// err = os.WriteFile(backupFileName, input, 0666)
// if err != nil {
// zap.S().Errorf("failed to write file %s: %s", backupFileName, err)
// return err
// }

err = os.WriteFile(f.settings.fileName, output, 0666)
if err != nil {
Expand Down

0 comments on commit 07ad10e

Please sign in to comment.