Skip to content

Commit

Permalink
refactor: edit command and docs (#6)
Browse files Browse the repository at this point in the history
* refactor: edit command and docs

* fix: export path

* feat(edit): add progress bar output

* chore: update go version and deps

* build: update actions workflow

* build: update actions workflow

* build: merge workflows

* chore: go mod tidy

* chore: add test

* chore: update go patch version

* chore: add test

* chore: add .gitignore
  • Loading branch information
zze0s authored Nov 13, 2024
1 parent 9949e6e commit 8180aef
Show file tree
Hide file tree
Showing 11 changed files with 319 additions and 180 deletions.
56 changes: 0 additions & 56 deletions .github/workflows/ci.yml

This file was deleted.

35 changes: 24 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ name: release

on:
push:
branches:
- "master"
tags:
- 'v*'
pull_request:

permissions:
contents: write
Expand All @@ -15,47 +18,57 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: '1.20.1'
go-version: '1.22.3'
cache: true

- name: Test
run: go test -v ./...


goreleaser:
name: Build & publish binaries
if: startsWith(github.ref, 'refs/tags/')
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: '1.20.1'
go-version: '1.22.3'
cache: true

- name: Run GoReleaser build
if: github.event_name == 'pull_request'
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean --skip=validate --skip=publish --parallelism 5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run GoReleaser build and publish tags
uses: goreleaser/goreleaser-action@v3
if: startsWith(github.ref, 'refs/tags/')
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload assets
uses: actions/upload-artifact@v3
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: migraterr
path: dist/*
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
test/*
bin
8 changes: 0 additions & 8 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@ archives:
- id: migraterr
builds:
- migraterr
files:
- none*
name_template: >-
{{ .ProjectName }}_
{{- .Version }}_
{{- .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else }}{{ .Arch }}{{ end }}

release:
prerelease: auto
Expand Down
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,24 @@ Available sub commands:

#### edit

Usage:
```shell
migraterr bencode edit "~/.sessions/*.torrent.rtorrent" --replace "/old/path/|/new/path/" --dry-run --verbose
migraterr bencode edit "~/.sessions/*.torrent.rtorrent" --replace "/old/path/|/new/path/" --export "./edited-files" -v
```

Required flags:
- `--glob` Glob to file(s) like `~/.sessions/*.torrent.rtorrent`
- `--replacements` Array of `oldvalue|newvalue` similar to `sed`.
- `--replace` Array of `oldvalue|newvalue` similar to `sed`.

Optional flags:
- `--dry-run` Do not edit any data
- `--verbose` Verbose output
- `--export /new/dir` Export edited files to new directory:
- `--export /new/dir` Export edited files to new directory:

#### info

Usage:
```shell
migraterr bencode info "~/.sessions/*.torrent.rtorrent"
migraterr bencode edit "~/.sessions/123.torrent.rtorrent"
```
Loading

0 comments on commit 8180aef

Please sign in to comment.