mirror of
https://github.com/muesli/mastotool
synced 2025-06-05 22:09:22 +02:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
9dfd746a5a | |||
2822457d13 | |||
01113437a3 | |||
9db7002e1f | |||
b727b5f719 | |||
4414c515df | |||
9c84b0037a |
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1 @@
|
||||
github: muesli
|
29
.github/workflows/build.yml
vendored
Normal file
29
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
name: build
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: [1.11.x, 1.12.x, 1.13.x, 1.14.x, 1.15.x]
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
GO111MODULE: "on"
|
||||
steps:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v1
|
||||
|
||||
- name: Download Go modules
|
||||
run: go mod download
|
||||
|
||||
- name: Build
|
||||
run: go build -v ./...
|
||||
|
||||
- name: Test
|
||||
run: go test ./...
|
@ -2,14 +2,15 @@ env:
|
||||
- GO111MODULE=on
|
||||
before:
|
||||
hooks:
|
||||
- go mod download
|
||||
- go mod download
|
||||
builds:
|
||||
-
|
||||
- id: "mastotool"
|
||||
binary: mastotool
|
||||
ldflags: -s -w -X main.Version={{ .Version }} -X main.CommitSHA={{ .Commit }}
|
||||
goos:
|
||||
- linux
|
||||
- darwin
|
||||
- freebsd
|
||||
- windows
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
@ -18,29 +19,69 @@ builds:
|
||||
goarm:
|
||||
- 6
|
||||
- 7
|
||||
ignore:
|
||||
- goos: darwin
|
||||
goarch: 386
|
||||
- goos: linux
|
||||
goarch: arm
|
||||
goarm: 7
|
||||
sign:
|
||||
artifacts: checksum
|
||||
- id: "darwin"
|
||||
binary: "mastotool"
|
||||
ldflags: -s -w -X main.Version={{ .Version }} -X main.CommitSHA={{ .Commit }}
|
||||
goos:
|
||||
- darwin
|
||||
goarch:
|
||||
- amd64
|
||||
|
||||
archives:
|
||||
-
|
||||
- id: default
|
||||
builds:
|
||||
- mastotool
|
||||
format_overrides:
|
||||
- goos: windows
|
||||
format: zip
|
||||
replacements:
|
||||
darwin: Darwin
|
||||
linux: Linux
|
||||
windows: Windows
|
||||
386: i386
|
||||
amd64: x86_64
|
||||
- id: darwin
|
||||
builds:
|
||||
- darwin
|
||||
replacements:
|
||||
darwin: Darwin
|
||||
amd64: x86_64
|
||||
|
||||
nfpms:
|
||||
- builds:
|
||||
- mastotool
|
||||
|
||||
vendor: muesli
|
||||
homepage: "https://fribbledom.com/"
|
||||
maintainer: "Christian Muehlhaeuser <muesli@gmail.com>"
|
||||
description: "Mastodon CLI tool & statistics generator"
|
||||
license: MIT
|
||||
formats:
|
||||
- deb
|
||||
- rpm
|
||||
bindir: /usr/bin
|
||||
|
||||
brews:
|
||||
- ids:
|
||||
- darwin
|
||||
tap:
|
||||
owner: muesli
|
||||
name: homebrew-tap
|
||||
commit_author:
|
||||
name: "Christian Muehlhaeuser"
|
||||
email: "muesli@gmail.com"
|
||||
homepage: "https://fribbledom.com/"
|
||||
description: "Mastodon CLI tool & statistics generator"
|
||||
# skip_upload: true
|
||||
|
||||
signs:
|
||||
- artifacts: checksum
|
||||
|
||||
checksum:
|
||||
name_template: 'checksums.txt'
|
||||
name_template: "checksums.txt"
|
||||
snapshot:
|
||||
name_template: "{{ .Tag }}-next"
|
||||
changelog:
|
||||
sort: asc
|
||||
filters:
|
||||
exclude:
|
||||
- '^docs:'
|
||||
- '^test:'
|
||||
- "^docs:"
|
||||
- "^test:"
|
||||
|
26
.travis.yml
26
.travis.yml
@ -1,26 +0,0 @@
|
||||
language: go
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
go:
|
||||
- 1.9.x
|
||||
- 1.10.x
|
||||
- 1.11.x
|
||||
- 1.12.x
|
||||
- 1.13.x
|
||||
- tip
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- go: tip
|
||||
|
||||
env:
|
||||
global:
|
||||
GO111MODULE=on
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: change
|
||||
on_failure: always
|
11
README.md
11
README.md
@ -1,6 +1,11 @@
|
||||
mastotool
|
||||
=========
|
||||
|
||||
[](https://github.com/muesli/mastotool/releases)
|
||||
[](https://github.com/muesli/mastotool/actions)
|
||||
[](http://goreportcard.com/report/muesli/mastotool)
|
||||
[](https://pkg.go.dev/github.com/muesli/mastotool)
|
||||
|
||||
mastotool offers a collection of tools to work with your Mastodon account
|
||||
|
||||
## Installation
|
||||
@ -119,9 +124,3 @@ Tags used that got the most boosts Boos
|
||||
Some tag 5
|
||||
Another tag 1
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
[](https://godoc.org/github.com/muesli/mastotool)
|
||||
[](https://travis-ci.org/muesli/mastotool)
|
||||
[](http://goreportcard.com/report/muesli/mastotool)
|
||||
|
3
go.mod
3
go.mod
@ -3,9 +3,10 @@ module github.com/muesli/mastotool
|
||||
go 1.15
|
||||
|
||||
require (
|
||||
github.com/jedib0t/go-pretty/v6 v6.0.4
|
||||
github.com/mattn/go-mastodon v0.0.5-0.20190808074743-8a48862adc29
|
||||
github.com/microcosm-cc/bluemonday v1.0.1
|
||||
github.com/muesli/goprogressbar v0.0.0-20180221033428-8ba388894ed9
|
||||
github.com/muesli/gotable v0.0.0-20180521192606-513fc87bb47c
|
||||
github.com/spf13/cobra v0.0.5
|
||||
github.com/stretchr/testify v1.3.0 // indirect
|
||||
)
|
||||
|
15
go.sum
15
go.sum
@ -6,6 +6,8 @@ github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc
|
||||
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
@ -14,22 +16,27 @@ github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoA
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/jedib0t/go-pretty/v6 v6.0.4 h1:7WaHUeKo5yc2vABlsh30p4VWxQoXaWktBY/nR/2qnPg=
|
||||
github.com/jedib0t/go-pretty/v6 v6.0.4/go.mod h1:MTr6FgcfNdnN5wPVBzJ6mhJeDyiF0yBvS2TMXEV/XSU=
|
||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
|
||||
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-mastodon v0.0.5-0.20190808074743-8a48862adc29 h1:p3d+nZHO9GDhvUBM1hEdr65dvI2L6cNngwuZ/YY55KM=
|
||||
github.com/mattn/go-mastodon v0.0.5-0.20190808074743-8a48862adc29/go.mod h1:ZBkemyyYYhNAN5JJ0H/ZSW8HfPCW45rHFHyWNwSfpTA=
|
||||
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/mattn/go-tty v0.0.0-20190424173100-523744f04859/go.mod h1:XPvLUNfbS4fJH25nqRHfWLMa1ONC8Amw+mIA639KxkE=
|
||||
github.com/microcosm-cc/bluemonday v1.0.1 h1:SIYunPjnlXcW+gVfvm0IlSeR5U3WZUOLfVmqg85Go44=
|
||||
github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/muesli/goprogressbar v0.0.0-20180221033428-8ba388894ed9 h1:UD88B1EJwL8Lade/0iOy9YGaRb9PkGFse9bqzZb4odg=
|
||||
github.com/muesli/goprogressbar v0.0.0-20180221033428-8ba388894ed9/go.mod h1:F7QqN7y15ODymk1BQifvSMHCqbHeBJH73/Nru18Ns7c=
|
||||
github.com/muesli/gotable v0.0.0-20180521192606-513fc87bb47c h1:FenLlkB2dgPh+14ME2KGwFjkJdcUc9WhqyAILCwRUdA=
|
||||
github.com/muesli/gotable v0.0.0-20180521192606-513fc87bb47c/go.mod h1:WPZDVvUBllqwXeaXhSmOSQiqjxBT5MzDBmW3qyOC09s=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
@ -40,7 +47,10 @@ github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb6
|
||||
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 h1:nrZ3ySNYwJbSpD6ce9duiP+QkD3JuLCcWkdaehUS/3Y=
|
||||
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80/go.mod h1:iFyPdL66DjUD96XmzVL3ZntbzcflLnznH0fr99w5VqE=
|
||||
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||
@ -54,6 +64,7 @@ golang.org/x/net v0.0.0-20181114220301-adae6a3d119a h1:gOpx8G595UYyvj8UK4+OFyY4r
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5 h1:6M3SDHlHHDCx2PcQw3S4KsR170vGqDhJDOmpVd4Hjak=
|
||||
golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/sys v0.0.0-20180816055513-1c9583448a9c/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
|
@ -49,7 +49,7 @@ func search(token string) error {
|
||||
abort := false
|
||||
for _, s := range statuses {
|
||||
if strings.Contains(strings.ToLower(cleanupContent(s.Content)), token) {
|
||||
fmt.Println("\nFound toot:", cleanupContent(s.Content))
|
||||
fmt.Println("\n\nFound toot:", cleanupContent(s.Content))
|
||||
fmt.Println("Date:", s.CreatedAt.Format(time.RFC822))
|
||||
fmt.Println("URL:", s.URL)
|
||||
fmt.Println()
|
||||
|
35
stats.go
35
stats.go
@ -5,15 +5,15 @@ import (
|
||||
"fmt"
|
||||
"html"
|
||||
"math"
|
||||
"os"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
mastodon "github.com/mattn/go-mastodon"
|
||||
"github.com/microcosm-cc/bluemonday"
|
||||
"github.com/muesli/goprogressbar"
|
||||
"github.com/muesli/gotable"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@ -246,23 +246,34 @@ func printTable(cols []string, emptyText string, data []kv) {
|
||||
return data[i].Value > data[j].Value
|
||||
})
|
||||
|
||||
col1 := columns - len(cols[1])
|
||||
col2 := len(cols[1])
|
||||
tab := gotable.NewTable(cols,
|
||||
[]int64{-int64(col1), int64(col2)},
|
||||
emptyText)
|
||||
col1 := columns - len(cols[1]) - 8
|
||||
// col2 := len(cols[1])
|
||||
|
||||
tab := table.NewWriter()
|
||||
tab.SetOutputMirror(os.Stdout)
|
||||
tab.SetStyle(table.StyleLight)
|
||||
tab.SetAllowedRowLength(columns)
|
||||
tab.AppendHeader(table.Row{cols[0], cols[1]})
|
||||
|
||||
tab.SetColumnConfigs([]table.ColumnConfig{
|
||||
{Name: cols[0], WidthMax: col1},
|
||||
{Name: cols[1]},
|
||||
})
|
||||
|
||||
for i, kv := range data {
|
||||
if i >= topN {
|
||||
break
|
||||
}
|
||||
if len(kv.Key) > col1-4 {
|
||||
kv.Key = kv.Key[:col1-4] + "..."
|
||||
}
|
||||
/*
|
||||
if runewidth.StringWidth(kv.Key) > col1-4 {
|
||||
kv.Key = kv.Key[:col1-4] + "..."
|
||||
}
|
||||
*/
|
||||
|
||||
tab.AppendRow([]interface{}{kv.Key, strconv.FormatInt(int64(kv.Value), 10)})
|
||||
tab.AppendRow([]interface{}{kv.Key, kv.Value})
|
||||
tab.AppendSeparator()
|
||||
}
|
||||
tab.Print()
|
||||
tab.Render()
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user