Compare commits
5 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bbdbffd789 | |||
| 88aa81ff46 | |||
| ad8f7937b1 | |||
| 3c2c3cef57 | |||
| cd2bd65b79 |
4 changed files with 40 additions and 8 deletions
|
|
@ -1,2 +1,2 @@
|
||||||
{"id":"bd-3rr","title":"Fix -o flag: output filename not parsed correctly","description":"## Bug Report\n\nUsing the `-o` flag to specify an output filename causes errors. Instead of using the provided filename, the tool attempts to open/save `.xlsx` (empty basename) and prints memory addresses.\n\n## Reproduction\n\n```\ncsv2excel.exe -enc=windows1252 -o=test.xlsx .\\WDK-SiWo-20260103.csv\n```\n\n## Actual Output\n\n```\n0x3eb5d9d181b0\n0x3eb5d9d181c0\n0x3eb5d9d181d0\nFehler beim Öffnen .xlsx: open .xlsx: The system cannot find the file specified.\n✓ .\\WDK-SiWo-20260103.csv → Reiter \"WDK-SiWo-20260103\" (5324 Zeilen)\nFehler beim Speichern: unsupported workbook file format\n```\n\n## Analysis\n\n- Memory addresses being printed suggest a pointer/value is being passed where a string is expected (e.g. `fmt.Println(&flag)` instead of `fmt.Println(*flag)`)\n- The output path resolves to `.xlsx` instead of `test.xlsx`, meaning the flag value is not read correctly\n- The `unsupported workbook file format` error is a consequence of trying to open a non-existent file as a workbook\n\n## Acceptance Criteria\n- [ ] `csv2excel -o=test.xlsx input.csv` writes output to `test.xlsx`\n- [ ] No memory addresses are printed to stdout/stderr\n- [ ] Error message is shown if the output path is invalid/unwritable\n- [ ] Tests written and passing","status":"closed","priority":1,"issue_type":"bug","created_at":"2026-03-05T09:37:26.921804683Z","created_by":"oli","updated_at":"2026-03-05T09:56:12.843074108Z","closed_at":"2026-03-05T09:56:12.842163406Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0}
|
{"id":"bd-3rr","title":"Fix -o flag: output filename not parsed correctly","description":"## Bug Report\n\nUsing the `-o` flag to specify an output filename causes errors. Instead of using the provided filename, the tool attempts to open/save `.xlsx` (empty basename) and prints memory addresses.\n\n## Reproduction\n\n```\ncsv2excel.exe -enc=windows1252 -o=test.xlsx .\\WDK-SiWo-20260103.csv\n```\n\n## Actual Output\n\n```\n0x3eb5d9d181b0\n0x3eb5d9d181c0\n0x3eb5d9d181d0\nFehler beim Öffnen .xlsx: open .xlsx: The system cannot find the file specified.\n✓ .\\WDK-SiWo-20260103.csv → Reiter \"WDK-SiWo-20260103\" (5324 Zeilen)\nFehler beim Speichern: unsupported workbook file format\n```\n\n## Analysis\n\n- Memory addresses being printed suggest a pointer/value is being passed where a string is expected (e.g. `fmt.Println(&flag)` instead of `fmt.Println(*flag)`)\n- The output path resolves to `.xlsx` instead of `test.xlsx`, meaning the flag value is not read correctly\n- The `unsupported workbook file format` error is a consequence of trying to open a non-existent file as a workbook\n\n## Acceptance Criteria\n- [ ] `csv2excel -o=test.xlsx input.csv` writes output to `test.xlsx`\n- [ ] No memory addresses are printed to stdout/stderr\n- [ ] Error message is shown if the output path is invalid/unwritable\n- [ ] Tests written and passing","status":"closed","priority":1,"issue_type":"bug","created_at":"2026-03-05T09:37:26.921804683Z","created_by":"oli","updated_at":"2026-03-05T12:10:00.000000000Z","closed_at":"2026-03-05T12:10:00.000000000Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0}
|
||||||
{"id":"bd-bxt","title":"Add --version flag to CLI","description":"## Description\n\nAdd a `--version` flag to the `csv2excel` CLI that outputs version information including the version tag and build timestamp.\n\n## Expected Output\n\n```\ncsv2excel version v0.10.0-1-g3eb502a built 2026-02-19T14:30:13Z\n```\n\nThe version string should be injected at build time using Go linker flags (`-ldflags`), so that `git describe` and a build timestamp are embedded into the binary.\n\n## Implementation Notes\n\n- Define `version` and `buildDate` variables in `main.go` (or a dedicated `version.go`)\n- Inject values via `-ldflags \"-X main.version=... -X main.buildDate=...\"` during `mage Build`\n- Handle the `--version` / `-v` flag and print the version line, then exit 0\n\n## Acceptance Criteria\n- [ ] `csv2excel --version` prints a line matching `csv2excel version <git-describe> built <RFC3339-timestamp>`\n- [ ] Version and build date are injected at build time via ldflags in the Mage build targets\n- [ ] Running `csv2excel --version` exits with code 0\n- [ ] Default (unset) values produce a sensible fallback (e.g. `dev` / `unknown`)\n- [ ] Tests written and passing (if applicable)","status":"open","priority":2,"issue_type":"feature","created_at":"2026-03-05T09:22:40.538253362Z","created_by":"oli","updated_at":"2026-03-05T09:22:40.538253362Z","source_repo":".","compaction_level":0,"original_size":0}
|
{"id":"bd-bxt","title":"Add --version flag to CLI","description":"## Description\n\nAdd a `--version` flag to the `csv2excel` CLI that outputs version information including the version tag and build timestamp.\n\n## Expected Output\n\n```\ncsv2excel version v0.10.0-1-g3eb502a built 2026-02-19T14:30:13Z\n```\n\nThe version string should be injected at build time using Go linker flags (`-ldflags`), so that `git describe` and a build timestamp are embedded into the binary.\n\n## Implementation Notes\n\n- Define `version` and `buildDate` variables in `main.go` (or a dedicated `version.go`)\n- Inject values via `-ldflags \"-X main.version=... -X main.buildDate=...\"` during `mage Build`\n- Handle the `--version` / `-v` flag and print the version line, then exit 0\n\n## Acceptance Criteria\n- [ ] `csv2excel --version` prints a line matching `csv2excel version <git-describe> built <RFC3339-timestamp>`\n- [ ] Version and build date are injected at build time via ldflags in the Mage build targets\n- [ ] Running `csv2excel --version` exits with code 0\n- [ ] Default (unset) values produce a sensible fallback (e.g. `dev` / `unknown`)\n- [ ] Tests written and passing (if applicable)","status":"closed","priority":2,"issue_type":"feature","created_at":"2026-03-05T09:22:40.538253362Z","created_by":"oli","updated_at":"2026-03-05T12:10:00.000000000Z","closed_at":"2026-03-05T12:10:00.000000000Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [v0.1.1] - 2026-03-05
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- `-o` flag value was read as a pointer instead of a string, causing memory addresses to be printed and the output path to resolve to `.xlsx`
|
||||||
|
|
||||||
## [v0.1.0] - 2026-03-05
|
## [v0.1.0] - 2026-03-05
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/magefile/mage/mg"
|
"github.com/magefile/mage/mg"
|
||||||
"github.com/magefile/mage/sh"
|
"github.com/magefile/mage/sh"
|
||||||
|
|
@ -23,12 +24,9 @@ func ldflags() (string, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
commit = "none"
|
commit = "none"
|
||||||
}
|
}
|
||||||
buildDate, err := sh.Output("date", "-u", "+%Y-%m-%dT%H:%M:%SZ")
|
buildDate := time.Now().UTC().Format(time.RFC3339)
|
||||||
if err != nil {
|
|
||||||
buildDate = "unknown"
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
`-X csv2excel/internal/version.Version=%s -X csv2excel/internal/version.Commit=%s -X csv2excel/internal/version.BuildDate=%s`,
|
`-X code.beautifulmachines.dev/jakoubek/csv2excel/internal/version.Version=%s -X code.beautifulmachines.dev/jakoubek/csv2excel/internal/version.Commit=%s -X code.beautifulmachines.dev/jakoubek/csv2excel/internal/version.BuildDate=%s`,
|
||||||
version, commit, buildDate,
|
version, commit, buildDate,
|
||||||
), nil
|
), nil
|
||||||
}
|
}
|
||||||
|
|
@ -77,6 +75,7 @@ func BuildWindows() error {
|
||||||
|
|
||||||
// Install installs the binary to $GOBIN or $GOPATH/bin.
|
// Install installs the binary to $GOBIN or $GOPATH/bin.
|
||||||
func Install() error {
|
func Install() error {
|
||||||
|
mg.Deps(Build)
|
||||||
fmt.Println("Installing", binaryName, "...")
|
fmt.Println("Installing", binaryName, "...")
|
||||||
flags, err := ldflags()
|
flags, err := ldflags()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
29
main.go
29
main.go
|
|
@ -12,17 +12,31 @@ import (
|
||||||
"github.com/xuri/excelize/v2"
|
"github.com/xuri/excelize/v2"
|
||||||
"golang.org/x/text/encoding/charmap"
|
"golang.org/x/text/encoding/charmap"
|
||||||
"golang.org/x/text/transform"
|
"golang.org/x/text/transform"
|
||||||
|
|
||||||
|
"code.beautifulmachines.dev/jakoubek/csv2excel/internal/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
sep := flag.String("sep", "auto", "Trennzeichen: auto, ',', ';', '\\t'")
|
sep := flag.String("sep", "auto", "Trennzeichen: auto, ',', ';', '\\t'")
|
||||||
enc := flag.String("enc", "utf8", "Encoding: utf8, windows1252")
|
enc := flag.String("enc", "utf8", "Encoding: utf8, windows1252")
|
||||||
out := flag.String("o", "output.xlsx", "Ausgabedatei")
|
out := flag.String("o", "output.xlsx", "Ausgabedatei")
|
||||||
|
showVersion := flag.Bool("version", false, "Version anzeigen")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if *showVersion {
|
||||||
|
fmt.Printf("csv2excel %s (commit %s, built %s)\n", version.Version, version.Commit, version.BuildDate)
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PowerShell kann "-o=testdatei.xlsx" in "-o=testdatei" + ".xlsx" splitten
|
||||||
|
if filepath.Ext(*out) == "" {
|
||||||
|
*out += ".xlsx"
|
||||||
|
}
|
||||||
|
|
||||||
files := flag.Args()
|
files := flag.Args()
|
||||||
if len(files) == 0 {
|
if len(files) == 0 {
|
||||||
fmt.Fprintln(os.Stderr, "Verwendung: csv2xlsx [flags] datei1.csv datei2.csv ...")
|
fmt.Fprintln(os.Stderr, "Verwendung: csv2excel [flags] datei1.csv datei2.csv ...")
|
||||||
|
fmt.Fprintln(os.Stderr, "Tipp: In PowerShell Leerzeichen statt = verwenden: -o ausgabe.xlsx")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -36,6 +50,19 @@ func run(files []string, out, sep, enc string) error {
|
||||||
xlsx := excelize.NewFile()
|
xlsx := excelize.NewFile()
|
||||||
firstSheet := true
|
firstSheet := true
|
||||||
|
|
||||||
|
var csvFiles []string
|
||||||
|
for _, f := range files {
|
||||||
|
if strings.EqualFold(filepath.Ext(f), ".xlsx") {
|
||||||
|
fmt.Fprintf(os.Stderr, "Warnung: %s übersprungen – Excel-Datei als Input? Meintest du: -o=%s\n", f, f)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
csvFiles = append(csvFiles, f)
|
||||||
|
}
|
||||||
|
files = csvFiles
|
||||||
|
if len(files) == 0 {
|
||||||
|
return fmt.Errorf("keine CSV-Dateien zum Verarbeiten")
|
||||||
|
}
|
||||||
|
|
||||||
for _, path := range files {
|
for _, path := range files {
|
||||||
|
|
||||||
sheetName := strings.TrimSuffix(filepath.Base(path), filepath.Ext(path))
|
sheetName := strings.TrimSuffix(filepath.Base(path), filepath.Ext(path))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue