Skip to content

Commit

Permalink
cli: add output filename suffix for fitprint and fitdump (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
muktihari authored Apr 23, 2024
1 parent 2386ff2 commit b22396c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
29 changes: 27 additions & 2 deletions cmd/fitdump/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Fitdump
# FIT Dump CLI

Fitdump dumps the FIT file(s) into segmented bytes.

Expand All @@ -14,8 +14,33 @@ message_data | 1| 00000001 [1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6

## Usage

### Run

```sh
go run main.go triathlon_summary_last.fit

# dumped: "triathlon_summary_last.fit" -> "triathlon_summary_last.txt"
# FIT dumped: "triathlon_summary_last.fit" -> "triathlon_summary_last-fitdump.txt"
```

### Build or Install

#### Build

```sh
go build -o fitdump main.go
```

#### Install

```sh
go install .
```

#### Run the resulting Binary

```sh
fitdump triathlon_summary_last.fit

# Output:
# FIT dumped: "triathlon_summary_last.fit" -> "triathlon_summary_last-fitdump.txt"
```
2 changes: 1 addition & 1 deletion cmd/fitdump/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func textdump(path string) error {
if len(ext) < len(base) {
name = base[:len(base)-len(ext)]
}
name = name + ".txt"
name = name + "-fitdump.txt"

resultPath := filepath.Join(dir, name)
out, err := os.OpenFile(resultPath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)
Expand Down
4 changes: 2 additions & 2 deletions cmd/fitprint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A program to generate comprehensive human-readable `*.txt` file containing detai
go run main.go DeveloperData.fit

# Output:
📄 "DeveloperData.fit" -> "DeveloperData.txt"
📄 "DeveloperData.fit" -> "DeveloperData-fitprint.txt"
```

### Build or Install
Expand All @@ -33,7 +33,7 @@ go install .
fitprint DeveloperData.fit

# Output:
📄 "DeveloperData.fit" -> "DeveloperData.txt"
📄 "DeveloperData.fit" -> "DeveloperData-fitprint.txt"
```

## Sample Output
Expand Down
2 changes: 1 addition & 1 deletion cmd/fitprint/printer/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func Print(path string) error {
if len(ext) < len(base) {
name = base[:len(base)-len(ext)]
}
name = name + ".txt"
name = name + "-fitprint.txt"

resultPath := filepath.Join(dir, name)
out, err := os.OpenFile(resultPath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)
Expand Down

0 comments on commit b22396c

Please sign in to comment.