1
0
mirror of https://github.com/muesli/mastotool synced 2025-06-05 22:09:22 +02:00

5 Commits

4 changed files with 28 additions and 16 deletions

View File

@ -5,7 +5,7 @@ jobs:
build:
strategy:
matrix:
go-version: [1.13.x, 1.14.x, 1.15.x]
go-version: [~1.13, ^1]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
env:

View File

@ -5,11 +5,14 @@ before:
- go mod download
builds:
- id: "mastotool"
env:
- CGO_ENABLED=0
binary: mastotool
ldflags: -s -w -X main.Version={{ .Version }} -X main.CommitSHA={{ .Commit }}
goos:
- linux
- freebsd
- openbsd
- darwin
- windows
goarch:

View File

@ -6,14 +6,21 @@ mastotool
[![Go ReportCard](http://goreportcard.com/badge/muesli/mastotool)](http://goreportcard.com/report/muesli/mastotool)
[![GoDoc](https://godoc.org/github.com/golang/gddo?status.svg)](https://pkg.go.dev/github.com/muesli/mastotool)
mastotool offers a collection of tools to work with your Mastodon account
mastotool offers a collection of command-line tools to work with your Mastodon account
## Installation
### Packages & Binaries
### Packages
#### Linux
- Arch Linux: [mastotool](https://aur.archlinux.org/packages/mastotool/)
- [Binaries](https://github.com/muesli/mastotool/releases) for Linux, macOS & Windows
- [Packages](https://github.com/muesli/mastotool/releases) in Debian & RPM formats
#### macOS
- macOS with [Homebrew](https://brew.sh/): `brew tap muesli/tap && brew install mastotool`
### Binaries
- [Binaries](https://github.com/muesli/mastotool/releases) for Linux, FreeBSD, OpenBSD, macOS & Windows
### From source

26
main.go
View File

@ -22,6 +22,19 @@ var (
Short: "mastotool offers a collection of tools to work with your Mastodon account",
SilenceErrors: true,
SilenceUsage: true,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if err := initClient(); err != nil {
return err
}
var err error
self, err = client.GetAccountCurrentUser(context.Background())
if err != nil {
return fmt.Errorf("Can't retrieve user: %s", err)
}
return nil
},
}
)
@ -120,19 +133,8 @@ func initClient() error {
func main() {
RootCmd.PersistentFlags().StringVarP(&configFile, "config", "c", "mastodon.json", "uses the specified config file")
if err := initClient(); err != nil {
fmt.Println(err)
os.Exit(1)
}
var err error
self, err = client.GetAccountCurrentUser(context.Background())
if err != nil {
fmt.Printf("Can't retrieve user: %s\n", err)
os.Exit(1)
}
if err := RootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(-1)
os.Exit(1)
}
}