package tooter
import (
- "fmt"
- "os"
+ "log"
"git.vexingworkshop.com/signal9/dead-tooter/pkg/mastodon"
"github.com/spf13/cobra"
}
var getAccountCmd = &cobra.Command{
- Use: "get [id]",
+ Use: "get",
Short: "Get account info",
- Long: `Return information the account specified by [id]. If no id is supplied,
+ Long: `Return information the account specified by --id. If no id is supplied,
return information on the current logged in user.`,
PreRun: func(cmd *cobra.Command, args []string) {
err := account.VerifyCredentials(&mAPI)
if err != nil {
- fmt.Println("Failed to verify credentials.")
- os.Exit(1)
+ log.Fatal("Failed to verify credentials.")
}
},
acct, err := mastodon.GetAccount(accountID, &mAPI)
if err != nil {
- fmt.Println("Failed to get account.")
- os.Exit(1)
+ log.Fatal("Failed to get account.")
}
acct.DisplayLong()
PreRun: func(cmd *cobra.Command, args []string) {
err := account.VerifyCredentials(&mAPI)
if err != nil {
- fmt.Println("Failed to verify credentials.")
- os.Exit(1)
+ log.Fatal("Failed to verify credentials.")
}
},
Run: func(cmd *cobra.Command, args []string) {
followers, err := account.GetFollowers(&mAPI)
if err != nil {
- panic(err.Error())
+ log.Fatal(err.Error())
}
followers.Display()
PreRun: func(cmd *cobra.Command, args []string) {
err := account.VerifyCredentials(&mAPI)
if err != nil {
- fmt.Println("Failed to verify credentials.")
- os.Exit(1)
+ log.Fatal("Failed to verify credentials.")
}
},
Run: func(cmd *cobra.Command, args []string) {
following, err := account.GetFollowing(&mAPI)
if err != nil {
- fmt.Println("Failed to get following list.")
- os.Exit(1)
+ log.Fatal("Failed to get following list.")
}
following.Display()
PreRun: func(cmd *cobra.Command, args []string) {
err := account.VerifyCredentials(&mAPI)
if err != nil {
- fmt.Println("Failed to verify credentials.")
- os.Exit(1)
+ log.Fatal("Failed to verify credentials.")
}
},
Run: func(cmd *cobra.Command, args []string) {
lists, err := account.GetLists(&mAPI)
if err != nil {
- fmt.Println("Failed to get following list.")
- os.Exit(1)
+ log.Fatal("Failed to get following list.")
}
lists.Display()
PreRun: func(cmd *cobra.Command, args []string) {
err := account.VerifyCredentials(&mAPI)
if err != nil {
- fmt.Println("Failed to verify credentials.")
- os.Exit(1)
+ log.Fatal("Failed to verify credentials.")
}
},
Run: func(cmd *cobra.Command, args []string) {
statuses, err := account.GetStatuses(&mAPI)
if err != nil {
- fmt.Println("Failed to retrieve statuses.")
- os.Exit(1)
+ log.Fatal("Failed to retrieve statuses.")
}
statuses.Display()
--- /dev/null
+package tooter
+
+import (
+ "errors"
+ "log"
+
+ "github.com/spf13/cobra"
+ "github.com/spf13/cobra/doc"
+)
+
+func init() {
+ rootCmd.AddCommand(docCmd)
+}
+
+var docCmd = &cobra.Command{
+ Use: "doc",
+ Short: "Generate dead-tooter docs",
+ Long: "Generate markdown documentation for dead-tooter.",
+
+ Args: func(cmd *cobra.Command, args []string) error {
+ if len(args) < 1 {
+ return errors.New("Please provide path to document directory")
+ }
+ return nil
+ },
+
+ Run: func(cmd *cobra.Command, args []string) {
+ target := args[0]
+ err := doc.GenMarkdownTree(rootCmd, target)
+ if err != nil {
+ log.Fatal(err)
+ }
+ },
+}
import (
"errors"
- "fmt"
+ "log"
"git.vexingworkshop.com/signal9/dead-tooter/pkg/mastodon"
"github.com/spf13/cobra"
PreRun: func(cmd *cobra.Command, args []string) {
err := account.VerifyCredentials(&mAPI)
if err != nil {
- fmt.Printf("Unable to verify credentials: %s\n", err.Error())
- return
+ log.Fatalf("Unable to verify credentials: %s\n", err.Error())
}
},
Run: func(cmd *cobra.Command, args []string) {
list, err := mastodon.GetList(args[0], &mAPI)
if err != nil {
- panic(err.Error())
+ log.Fatal(err.Error())
}
accounts, err := list.GetAccounts(&mAPI)
if err != nil {
- panic(err.Error())
+ log.Fatal(err.Error())
}
accounts.Display()
PreRun: func(cmd *cobra.Command, args []string) {
err := account.VerifyCredentials(&mAPI)
if err != nil {
- panic(err.Error())
+ log.Fatal(err.Error())
}
},
lists, err := mastodon.ListsContainingAccount(id, &mAPI)
if err != nil {
- panic(err.Error())
+ log.Fatal(err.Error())
}
lists.Display()
package tooter
import (
- "fmt"
+ "log"
"git.vexingworkshop.com/signal9/dead-tooter/pkg/mastodon"
"github.com/spf13/cobra"
app, err = mastodon.Create(mAPI.Host, client)
if err != nil {
- fmt.Printf("Failed to create client: %s\n", err.Error())
+ log.Fatalf("Failed to create client: %s\n", err.Error())
}
err = app.Save()
if err != nil {
- fmt.Printf("Failed to store client info: %s\n", err.Error())
+ log.Fatalf("Failed to store client info: %s\n", err.Error())
}
}
var account mastodon.Account
code, err := account.Authorize(mAPI.Host, app)
if err != nil {
- fmt.Printf("Failed to authorize account: %s\n", err.Error())
+ log.Fatalf("Failed to authorize account: %s\n", err.Error())
}
mAPI.Token, err = account.RequestToken(mAPI.Host, app, code)
if err != nil {
- fmt.Printf("Failed to acquire request token: %s\n", err.Error())
+ log.Fatalf("Failed to acquire request token: %s\n", err.Error())
}
err = mAPI.Token.Save()
if err != nil {
- fmt.Printf("Failed to store access token: %s\n", err.Error())
+ log.Fatalf("Failed to store access token: %s\n", err.Error())
}
err = account.VerifyCredentials(&mAPI)
if err != nil {
- fmt.Printf("Failed to verify credentials: %s\n", err.Error())
+ log.Fatalf("Failed to verify credentials: %s\n", err.Error())
}
}
package tooter
import (
- "fmt"
- "os"
+ "log"
"git.vexingworkshop.com/signal9/dead-tooter/pkg/mastodon/api"
"github.com/spf13/cobra"
PersistentPreRun: func(cmd *cobra.Command, args []string) {
token, err := api.LoadToken()
if err != nil {
- fmt.Println("No authentication token found.")
+ log.Fatal("No authentication token found.")
}
mAPI.Token = token
},
PersistentPostRun: func(cmd *cobra.Command, args []string) {
err := mAPI.Token.Save()
if err != nil {
- panic(err.Error())
+ log.Fatal(err.Error())
}
},
}
// Execute base command.
func Execute() {
if err := rootCmd.Execute(); err != nil {
- fmt.Println(err)
- os.Exit(1)
+ log.Fatal(err)
}
}
--- /dev/null
+## dead-tooter
+
+A CLI for Mastodon hate scripts
+
+### Synopsis
+
+Provides a collection of capabilities that may or may not
+be present in the Mastodon web UI.
+
+### Options
+
+```
+ -h, --help help for dead-tooter
+ -H, --host string Mastodon host where your account lives.
+ --proxy string Address of proxy server.
+```
+
+### SEE ALSO
+
+* [dead-tooter account](dead-tooter_account.md) - Account commands
+* [dead-tooter application](dead-tooter_application.md) - Register and perform application-level actions
+* [dead-tooter completion](dead-tooter_completion.md) - Generate the autocompletion script for the specified shell
+* [dead-tooter docs](dead-tooter_docs.md) - Generate dead-tooter docs
+* [dead-tooter lists](dead-tooter_lists.md) - List commands
+* [dead-tooter login](dead-tooter_login.md) - Login to Mastodon
+* [dead-tooter version](dead-tooter_version.md) - Print the version number of d34d-t00ter
+
+###### Auto generated by spf13/cobra on 7-Jan-2023
--- /dev/null
+## dead-tooter account
+
+Account commands
+
+### Synopsis
+
+Commands related to the logged in Mastodon account.
+
+### Options
+
+```
+ -h, --help help for account
+ --id string ID of the Mastodon account
+```
+
+### Options inherited from parent commands
+
+```
+ -H, --host string Mastodon host where your account lives.
+ --proxy string Address of proxy server.
+```
+
+### SEE ALSO
+
+* [dead-tooter](dead-tooter.md) - A CLI for Mastodon hate scripts
+* [dead-tooter account followers](dead-tooter_account_followers.md) - Get account followers
+* [dead-tooter account following](dead-tooter_account_following.md) - Get accounts followed
+* [dead-tooter account get](dead-tooter_account_get.md) - Get account info
+* [dead-tooter account lists](dead-tooter_account_lists.md) - Get account's lists
+* [dead-tooter account statuses](dead-tooter_account_statuses.md) - Get account's statuses
+
+###### Auto generated by spf13/cobra on 7-Jan-2023
--- /dev/null
+## dead-tooter account followers
+
+Get account followers
+
+### Synopsis
+
+Get a list of followers for the current account.
+
+```
+dead-tooter account followers [flags]
+```
+
+### Options
+
+```
+ -h, --help help for followers
+```
+
+### Options inherited from parent commands
+
+```
+ -H, --host string Mastodon host where your account lives.
+ --id string ID of the Mastodon account
+ --proxy string Address of proxy server.
+```
+
+### SEE ALSO
+
+* [dead-tooter account](dead-tooter_account.md) - Account commands
+
+###### Auto generated by spf13/cobra on 7-Jan-2023
--- /dev/null
+## dead-tooter account following
+
+Get accounts followed
+
+### Synopsis
+
+Get a list of followed accounts for the current account.
+
+```
+dead-tooter account following [flags]
+```
+
+### Options
+
+```
+ -h, --help help for following
+```
+
+### Options inherited from parent commands
+
+```
+ -H, --host string Mastodon host where your account lives.
+ --id string ID of the Mastodon account
+ --proxy string Address of proxy server.
+```
+
+### SEE ALSO
+
+* [dead-tooter account](dead-tooter_account.md) - Account commands
+
+###### Auto generated by spf13/cobra on 7-Jan-2023
--- /dev/null
+## dead-tooter account get
+
+Get account info
+
+### Synopsis
+
+Return information the account specified by --id. If no id is supplied,
+return information on the current logged in user.
+
+```
+dead-tooter account get [flags]
+```
+
+### Options
+
+```
+ -h, --help help for get
+```
+
+### Options inherited from parent commands
+
+```
+ -H, --host string Mastodon host where your account lives.
+ --id string ID of the Mastodon account
+ --proxy string Address of proxy server.
+```
+
+### SEE ALSO
+
+* [dead-tooter account](dead-tooter_account.md) - Account commands
+
+###### Auto generated by spf13/cobra on 7-Jan-2023
--- /dev/null
+## dead-tooter account lists
+
+Get account's lists
+
+### Synopsis
+
+Fetch all lists the account owns
+
+```
+dead-tooter account lists [flags]
+```
+
+### Options
+
+```
+ -h, --help help for lists
+```
+
+### Options inherited from parent commands
+
+```
+ -H, --host string Mastodon host where your account lives.
+ --id string ID of the Mastodon account
+ --proxy string Address of proxy server.
+```
+
+### SEE ALSO
+
+* [dead-tooter account](dead-tooter_account.md) - Account commands
+
+###### Auto generated by spf13/cobra on 7-Jan-2023
--- /dev/null
+## dead-tooter account statuses
+
+Get account's statuses
+
+### Synopsis
+
+Fetch statuses posted by account.
+
+```
+dead-tooter account statuses [flags]
+```
+
+### Options
+
+```
+ -h, --help help for statuses
+```
+
+### Options inherited from parent commands
+
+```
+ -H, --host string Mastodon host where your account lives.
+ --id string ID of the Mastodon account
+ --proxy string Address of proxy server.
+```
+
+### SEE ALSO
+
+* [dead-tooter account](dead-tooter_account.md) - Account commands
+
+###### Auto generated by spf13/cobra on 7-Jan-2023
--- /dev/null
+## dead-tooter application
+
+Register and perform application-level actions
+
+### Synopsis
+
+application, man
+
+```
+dead-tooter application [flags]
+```
+
+### Options
+
+```
+ -h, --help help for application
+```
+
+### Options inherited from parent commands
+
+```
+ -H, --host string Mastodon host where your account lives.
+ --proxy string Address of proxy server.
+```
+
+### SEE ALSO
+
+* [dead-tooter](dead-tooter.md) - A CLI for Mastodon hate scripts
+
+###### Auto generated by spf13/cobra on 7-Jan-2023
--- /dev/null
+## dead-tooter completion
+
+Generate the autocompletion script for the specified shell
+
+### Synopsis
+
+Generate the autocompletion script for dead-tooter for the specified shell.
+See each sub-command's help for details on how to use the generated script.
+
+
+### Options
+
+```
+ -h, --help help for completion
+```
+
+### Options inherited from parent commands
+
+```
+ -H, --host string Mastodon host where your account lives.
+ --proxy string Address of proxy server.
+```
+
+### SEE ALSO
+
+* [dead-tooter](dead-tooter.md) - A CLI for Mastodon hate scripts
+* [dead-tooter completion bash](dead-tooter_completion_bash.md) - Generate the autocompletion script for bash
+* [dead-tooter completion fish](dead-tooter_completion_fish.md) - Generate the autocompletion script for fish
+* [dead-tooter completion powershell](dead-tooter_completion_powershell.md) - Generate the autocompletion script for powershell
+* [dead-tooter completion zsh](dead-tooter_completion_zsh.md) - Generate the autocompletion script for zsh
+
+###### Auto generated by spf13/cobra on 7-Jan-2023
--- /dev/null
+## dead-tooter completion bash
+
+Generate the autocompletion script for bash
+
+### Synopsis
+
+Generate the autocompletion script for the bash shell.
+
+This script depends on the 'bash-completion' package.
+If it is not installed already, you can install it via your OS's package manager.
+
+To load completions in your current shell session:
+
+ source <(dead-tooter completion bash)
+
+To load completions for every new session, execute once:
+
+#### Linux:
+
+ dead-tooter completion bash > /etc/bash_completion.d/dead-tooter
+
+#### macOS:
+
+ dead-tooter completion bash > $(brew --prefix)/etc/bash_completion.d/dead-tooter
+
+You will need to start a new shell for this setup to take effect.
+
+
+```
+dead-tooter completion bash
+```
+
+### Options
+
+```
+ -h, --help help for bash
+ --no-descriptions disable completion descriptions
+```
+
+### Options inherited from parent commands
+
+```
+ -H, --host string Mastodon host where your account lives.
+ --proxy string Address of proxy server.
+```
+
+### SEE ALSO
+
+* [dead-tooter completion](dead-tooter_completion.md) - Generate the autocompletion script for the specified shell
+
+###### Auto generated by spf13/cobra on 7-Jan-2023
--- /dev/null
+## dead-tooter completion fish
+
+Generate the autocompletion script for fish
+
+### Synopsis
+
+Generate the autocompletion script for the fish shell.
+
+To load completions in your current shell session:
+
+ dead-tooter completion fish | source
+
+To load completions for every new session, execute once:
+
+ dead-tooter completion fish > ~/.config/fish/completions/dead-tooter.fish
+
+You will need to start a new shell for this setup to take effect.
+
+
+```
+dead-tooter completion fish [flags]
+```
+
+### Options
+
+```
+ -h, --help help for fish
+ --no-descriptions disable completion descriptions
+```
+
+### Options inherited from parent commands
+
+```
+ -H, --host string Mastodon host where your account lives.
+ --proxy string Address of proxy server.
+```
+
+### SEE ALSO
+
+* [dead-tooter completion](dead-tooter_completion.md) - Generate the autocompletion script for the specified shell
+
+###### Auto generated by spf13/cobra on 7-Jan-2023
--- /dev/null
+## dead-tooter completion powershell
+
+Generate the autocompletion script for powershell
+
+### Synopsis
+
+Generate the autocompletion script for powershell.
+
+To load completions in your current shell session:
+
+ dead-tooter completion powershell | Out-String | Invoke-Expression
+
+To load completions for every new session, add the output of the above command
+to your powershell profile.
+
+
+```
+dead-tooter completion powershell [flags]
+```
+
+### Options
+
+```
+ -h, --help help for powershell
+ --no-descriptions disable completion descriptions
+```
+
+### Options inherited from parent commands
+
+```
+ -H, --host string Mastodon host where your account lives.
+ --proxy string Address of proxy server.
+```
+
+### SEE ALSO
+
+* [dead-tooter completion](dead-tooter_completion.md) - Generate the autocompletion script for the specified shell
+
+###### Auto generated by spf13/cobra on 7-Jan-2023
--- /dev/null
+## dead-tooter completion zsh
+
+Generate the autocompletion script for zsh
+
+### Synopsis
+
+Generate the autocompletion script for the zsh shell.
+
+If shell completion is not already enabled in your environment you will need
+to enable it. You can execute the following once:
+
+ echo "autoload -U compinit; compinit" >> ~/.zshrc
+
+To load completions in your current shell session:
+
+ source <(dead-tooter completion zsh); compdef _dead-tooter dead-tooter
+
+To load completions for every new session, execute once:
+
+#### Linux:
+
+ dead-tooter completion zsh > "${fpath[1]}/_dead-tooter"
+
+#### macOS:
+
+ dead-tooter completion zsh > $(brew --prefix)/share/zsh/site-functions/_dead-tooter
+
+You will need to start a new shell for this setup to take effect.
+
+
+```
+dead-tooter completion zsh [flags]
+```
+
+### Options
+
+```
+ -h, --help help for zsh
+ --no-descriptions disable completion descriptions
+```
+
+### Options inherited from parent commands
+
+```
+ -H, --host string Mastodon host where your account lives.
+ --proxy string Address of proxy server.
+```
+
+### SEE ALSO
+
+* [dead-tooter completion](dead-tooter_completion.md) - Generate the autocompletion script for the specified shell
+
+###### Auto generated by spf13/cobra on 7-Jan-2023
--- /dev/null
+## dead-tooter docs
+
+Generate dead-tooter docs
+
+### Synopsis
+
+Generate markdown documentation for dead-tooter.
+
+```
+dead-tooter docs [flags]
+```
+
+### Options
+
+```
+ -h, --help help for docs
+```
+
+### Options inherited from parent commands
+
+```
+ -H, --host string Mastodon host where your account lives.
+ --proxy string Address of proxy server.
+```
+
+### SEE ALSO
+
+* [dead-tooter](dead-tooter.md) - A CLI for Mastodon hate scripts
+
+###### Auto generated by spf13/cobra on 7-Jan-2023
--- /dev/null
+## dead-tooter lists
+
+List commands
+
+### Synopsis
+
+Commands related to account lists.
+
+### Options
+
+```
+ -h, --help help for lists
+```
+
+### Options inherited from parent commands
+
+```
+ -H, --host string Mastodon host where your account lives.
+ --proxy string Address of proxy server.
+```
+
+### SEE ALSO
+
+* [dead-tooter](dead-tooter.md) - A CLI for Mastodon hate scripts
+* [dead-tooter lists accounts](dead-tooter_lists_accounts.md) - Get list accounts
+* [dead-tooter lists containing](dead-tooter_lists_containing.md) - Get lists containing [accountid]
+
+###### Auto generated by spf13/cobra on 7-Jan-2023
--- /dev/null
+## dead-tooter lists accounts
+
+Get list accounts
+
+### Synopsis
+
+Get accounts in a list
+
+```
+dead-tooter lists accounts [flags]
+```
+
+### Options
+
+```
+ -h, --help help for accounts
+```
+
+### Options inherited from parent commands
+
+```
+ -H, --host string Mastodon host where your account lives.
+ --proxy string Address of proxy server.
+```
+
+### SEE ALSO
+
+* [dead-tooter lists](dead-tooter_lists.md) - List commands
+
+###### Auto generated by spf13/cobra on 7-Jan-2023
--- /dev/null
+## dead-tooter lists containing
+
+Get lists containing [accountid]
+
+### Synopsis
+
+Get lists containing a specified account
+
+```
+dead-tooter lists containing [flags]
+```
+
+### Options
+
+```
+ -h, --help help for containing
+```
+
+### Options inherited from parent commands
+
+```
+ -H, --host string Mastodon host where your account lives.
+ --proxy string Address of proxy server.
+```
+
+### SEE ALSO
+
+* [dead-tooter lists](dead-tooter_lists.md) - List commands
+
+###### Auto generated by spf13/cobra on 7-Jan-2023
--- /dev/null
+## dead-tooter login
+
+Login to Mastodon
+
+### Synopsis
+
+Initiate login to your Mastodon server of choice
+
+```
+dead-tooter login [flags]
+```
+
+### Options
+
+```
+ -h, --help help for login
+```
+
+### Options inherited from parent commands
+
+```
+ -H, --host string Mastodon host where your account lives.
+ --proxy string Address of proxy server.
+```
+
+### SEE ALSO
+
+* [dead-tooter](dead-tooter.md) - A CLI for Mastodon hate scripts
+
+###### Auto generated by spf13/cobra on 7-Jan-2023
--- /dev/null
+## dead-tooter version
+
+Print the version number of d34d-t00ter
+
+### Synopsis
+
+Version, man, version!
+
+```
+dead-tooter version [flags]
+```
+
+### Options
+
+```
+ -h, --help help for version
+```
+
+### Options inherited from parent commands
+
+```
+ -H, --host string Mastodon host where your account lives.
+ --proxy string Address of proxy server.
+```
+
+### SEE ALSO
+
+* [dead-tooter](dead-tooter.md) - A CLI for Mastodon hate scripts
+
+###### Auto generated by spf13/cobra on 7-Jan-2023
require github.com/spf13/cobra v1.6.1
require (
+ github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
+ github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
+ gopkg.in/yaml.v3 v3.0.1 // indirect
)
+github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
+github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=