+++ /dev/null
-package tooter
-
-import (
- "log"
-
- "git.vexingworkshop.com/signal9/dead-tooter/pkg/mastodon"
- "github.com/spf13/cobra"
-)
-
-var accountID string
-var account mastodon.Account
-
-func init() {
- accountCmd.PersistentFlags().StringVarP(&accountID, "id", "", "", "ID of the Mastodon account")
-
- accountCmd.AddCommand(getAccountCmd)
- accountCmd.AddCommand(getFollowersCmd)
- accountCmd.AddCommand(getFollowingCmd)
- accountCmd.AddCommand(getListsCmd)
- accountCmd.AddCommand(getStatusesCmd)
-
- rootCmd.AddCommand(accountCmd)
-}
-
-var accountCmd = &cobra.Command{
- Use: "account",
- Short: "Account commands",
- Long: "Commands related to the logged in Mastodon account.",
-}
-
-var getAccountCmd = &cobra.Command{
- Use: "get",
- Short: "Get account info",
- 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 {
- log.Fatal("Failed to verify credentials.")
- }
- },
-
- Run: func(cmd *cobra.Command, args []string) {
- if accountID == "" {
- accountID = account.ID
- }
-
- acct, err := mastodon.GetAccount(accountID, &mAPI)
- if err != nil {
- log.Fatal("Failed to get account.")
- }
-
- acct.DisplayLong()
- },
-}
-
-var getFollowersCmd = &cobra.Command{
- Use: "followers",
- Short: "Get account followers",
- Long: "Get a list of followers for the current account.",
-
- PreRun: func(cmd *cobra.Command, args []string) {
- err := account.VerifyCredentials(&mAPI)
- if err != nil {
- log.Fatal("Failed to verify credentials.")
- }
- },
-
- Run: func(cmd *cobra.Command, args []string) {
- if accountID == "" {
- accountID = account.ID
- }
-
- followers, err := mastodon.GetFollowers(accountID, &mAPI)
- if err != nil {
- log.Fatal(err.Error())
- }
-
- followers.Display()
- },
-}
-
-var getFollowingCmd = &cobra.Command{
- Use: "following",
- Short: "Get accounts followed",
- Long: "Get a list of followed accounts for the current account.",
-
- PreRun: func(cmd *cobra.Command, args []string) {
- err := account.VerifyCredentials(&mAPI)
- if err != nil {
- log.Fatal("Failed to verify credentials.")
- }
- },
-
- Run: func(cmd *cobra.Command, args []string) {
- if accountID == "" {
- accountID = account.ID
- }
-
- following, err := mastodon.GetFollowing(accountID, &mAPI)
- if err != nil {
- log.Fatal("Failed to get following list.")
- }
-
- following.Display()
- },
-}
-
-var getListsCmd = &cobra.Command{
- Use: "lists",
- Short: "Get account's lists",
- Long: "Fetch all lists the account owns",
-
- PreRun: func(cmd *cobra.Command, args []string) {
- err := account.VerifyCredentials(&mAPI)
- if err != nil {
- log.Fatal("Failed to verify credentials.")
- }
- },
-
- Run: func(cmd *cobra.Command, args []string) {
- lists, err := account.GetLists(&mAPI)
- if err != nil {
- log.Fatal("Failed to get following list.")
- }
-
- lists.Display()
- },
-}
-
-var getStatusesCmd = &cobra.Command{
- Use: "statuses",
- Short: "Get account's statuses",
- Long: "Fetch statuses posted by account.",
-
- PreRun: func(cmd *cobra.Command, args []string) {
- err := account.VerifyCredentials(&mAPI)
- if err != nil {
- log.Fatal("Failed to verify credentials.")
- }
- },
-
- Run: func(cmd *cobra.Command, args []string) {
- if accountID == "" {
- accountID = account.ID
- }
- statuses, err := mastodon.GetStatuses(accountID, &mAPI)
- if err != nil {
- log.Fatal("Failed to retrieve statuses.")
- }
-
- statuses.Display()
- },
-}
+++ /dev/null
-package tooter
-
-import "github.com/spf13/cobra"
-
-func init() {
- rootCmd.AddCommand(cmdApp)
-}
-
-var cmdApp = &cobra.Command{
- Use: "application",
- Short: "Register and perform application-level actions",
- Long: "application, man",
- Run: func(cmd *cobra.Command, args []string) {
- },
-}
--- /dev/null
+package tooter
+
+import (
+ "log"
+
+ "git.vexingworkshop.com/signal9/dead-tooter/pkg/mastodon"
+ "github.com/spf13/cobra"
+)
+
+var accountID string
+var account mastodon.Account
+
+func init() {
+ accountCmd.PersistentFlags().StringVarP(&accountID, "id", "", "", "ID of the Mastodon account")
+
+ accountCmd.AddCommand(getAccountCmd)
+ accountCmd.AddCommand(getFollowersCmd)
+ accountCmd.AddCommand(getFollowingCmd)
+ accountCmd.AddCommand(getListsCmd)
+ accountCmd.AddCommand(getStatusesCmd)
+
+ rootCmd.AddCommand(accountCmd)
+}
+
+var accountCmd = &cobra.Command{
+ Use: "account",
+ Short: "Account commands",
+ Long: "Commands related to the logged in Mastodon account.",
+}
+
+var getAccountCmd = &cobra.Command{
+ Use: "get",
+ Short: "Get account info",
+ 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 {
+ log.Fatal("Failed to verify credentials.")
+ }
+ },
+
+ Run: func(cmd *cobra.Command, args []string) {
+ if accountID == "" {
+ accountID = account.ID
+ }
+
+ acct, err := mastodon.GetAccount(accountID, &mAPI)
+ if err != nil {
+ log.Fatal("Failed to get account.")
+ }
+
+ acct.DisplayLong()
+ },
+}
+
+var getFollowersCmd = &cobra.Command{
+ Use: "followers",
+ Short: "Get account followers",
+ Long: "Get a list of followers for the current account.",
+
+ PreRun: func(cmd *cobra.Command, args []string) {
+ err := account.VerifyCredentials(&mAPI)
+ if err != nil {
+ log.Fatal("Failed to verify credentials.")
+ }
+ },
+
+ Run: func(cmd *cobra.Command, args []string) {
+ if accountID == "" {
+ accountID = account.ID
+ }
+
+ followers, err := mastodon.GetFollowers(accountID, &mAPI)
+ if err != nil {
+ log.Fatal(err.Error())
+ }
+
+ followers.Display()
+ },
+}
+
+var getFollowingCmd = &cobra.Command{
+ Use: "following",
+ Short: "Get accounts followed",
+ Long: "Get a list of followed accounts for the current account.",
+
+ PreRun: func(cmd *cobra.Command, args []string) {
+ err := account.VerifyCredentials(&mAPI)
+ if err != nil {
+ log.Fatal("Failed to verify credentials.")
+ }
+ },
+
+ Run: func(cmd *cobra.Command, args []string) {
+ if accountID == "" {
+ accountID = account.ID
+ }
+
+ following, err := mastodon.GetFollowing(accountID, &mAPI)
+ if err != nil {
+ log.Fatal("Failed to get following list.")
+ }
+
+ following.Display()
+ },
+}
+
+var getListsCmd = &cobra.Command{
+ Use: "lists",
+ Short: "Get account's lists",
+ Long: "Fetch all lists the account owns",
+
+ PreRun: func(cmd *cobra.Command, args []string) {
+ err := account.VerifyCredentials(&mAPI)
+ if err != nil {
+ log.Fatal("Failed to verify credentials.")
+ }
+ },
+
+ Run: func(cmd *cobra.Command, args []string) {
+ lists, err := account.GetLists(&mAPI)
+ if err != nil {
+ log.Fatal("Failed to get following list.")
+ }
+
+ lists.Display()
+ },
+}
+
+var getStatusesCmd = &cobra.Command{
+ Use: "statuses",
+ Short: "Get account's statuses",
+ Long: "Fetch statuses posted by account.",
+
+ PreRun: func(cmd *cobra.Command, args []string) {
+ err := account.VerifyCredentials(&mAPI)
+ if err != nil {
+ log.Fatal("Failed to verify credentials.")
+ }
+ },
+
+ Run: func(cmd *cobra.Command, args []string) {
+ if accountID == "" {
+ accountID = account.ID
+ }
+ statuses, err := mastodon.GetStatuses(accountID, &mAPI)
+ if err != nil {
+ log.Fatal("Failed to retrieve statuses.")
+ }
+
+ statuses.Display()
+ },
+}
--- /dev/null
+package tooter
+
+import "github.com/spf13/cobra"
+
+func init() {
+ rootCmd.AddCommand(cmdApp)
+}
+
+var cmdApp = &cobra.Command{
+ Use: "application",
+ Short: "Register and perform application-level actions",
+ Long: "application, man",
+ Run: func(cmd *cobra.Command, args []string) {
+ },
+}
--- /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)
+ }
+ },
+}
--- /dev/null
+package tooter
+
+import (
+ "errors"
+ "log"
+
+ "git.vexingworkshop.com/signal9/dead-tooter/pkg/mastodon"
+ "github.com/spf13/cobra"
+)
+
+func init() {
+ listCmd.AddCommand(listAccountsCmd)
+ listCmd.AddCommand(listsContainingCmd)
+
+ rootCmd.AddCommand(listCmd)
+}
+
+var listCmd = &cobra.Command{
+ Use: "lists",
+ Short: "List commands",
+ Long: "Commands related to account lists.",
+}
+
+var listAccountsCmd = &cobra.Command{
+ Use: "accounts",
+ Short: "Get list accounts",
+ Long: "Get accounts in a list",
+
+ Args: func(cmd *cobra.Command, args []string) error {
+ if len(args) < 1 {
+ return errors.New("Must provide list id")
+ }
+ return nil
+ },
+
+ PreRun: func(cmd *cobra.Command, args []string) {
+ err := account.VerifyCredentials(&mAPI)
+ if err != nil {
+ 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 {
+ log.Fatal(err.Error())
+ }
+
+ accounts, err := list.GetAccounts(&mAPI)
+ if err != nil {
+ log.Fatal(err.Error())
+ }
+
+ print(accounts)
+ },
+}
+
+var listsContainingCmd = &cobra.Command{
+ Use: "containing",
+ Short: "Get lists containing [accountid]",
+ Long: "Get lists containing a specified account",
+
+ PreRun: func(cmd *cobra.Command, args []string) {
+ err := account.VerifyCredentials(&mAPI)
+ if err != nil {
+ log.Fatal(err.Error())
+ }
+ },
+
+ Run: func(cmd *cobra.Command, args []string) {
+ var id string
+
+ if len(args) < 1 {
+ id = account.ID
+ } else {
+ id = args[0]
+ }
+
+ lists, err := mastodon.ListsContainingAccount(id, &mAPI)
+ if err != nil {
+ log.Fatal(err.Error())
+ }
+
+ lists.Display()
+ },
+}
--- /dev/null
+package tooter
+
+import (
+ "log"
+
+ "git.vexingworkshop.com/signal9/dead-tooter/pkg/mastodon"
+ "github.com/spf13/cobra"
+)
+
+func init() {
+ rootCmd.AddCommand(loginCmd)
+}
+
+var loginCmd = &cobra.Command{
+ Use: "login",
+ Short: "Login to Mastodon",
+ Long: "Initiate login to your Mastodon server of choice",
+ Run: func(cmd *cobra.Command, args []string) {
+ login()
+ },
+}
+
+func login() {
+ app, err := mastodon.Load("dead-tooter")
+ if err != nil {
+ client := mastodon.Client{
+ ClientName: "dead-tooter",
+ RedirectUris: mastodon.RedirectUris,
+ Scopes: "read write follow push",
+ Website: "https://dead-tooter.vexingworkshop.com",
+ }
+
+ app, err = mastodon.Create(mAPI.Host, client)
+ if err != nil {
+ log.Fatalf("Failed to create client: %s\n", err.Error())
+ }
+
+ err = app.Save()
+ if err != nil {
+ 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 {
+ log.Fatalf("Failed to authorize account: %s\n", err.Error())
+ }
+
+ mAPI.Token, err = account.RequestToken(mAPI.Host, app, code)
+ if err != nil {
+ log.Fatalf("Failed to acquire request token: %s\n", err.Error())
+ }
+
+ err = mAPI.Token.Save()
+ if err != nil {
+ log.Fatalf("Failed to store access token: %s\n", err.Error())
+ }
+
+ err = account.VerifyCredentials(&mAPI)
+ if err != nil {
+ log.Fatalf("Failed to verify credentials: %s\n", err.Error())
+ }
+}
--- /dev/null
+package tooter
+
+import (
+ "log"
+
+ "git.vexingworkshop.com/signal9/dead-tooter/pkg/mastodon/api"
+ "github.com/spf13/cobra"
+)
+
+var mAPI = api.API{}
+
+func init() {
+ rootCmd.PersistentFlags().StringVarP(&mAPI.Host,
+ "host", "H", "", "Mastodon host where your account lives.")
+ rootCmd.MarkPersistentFlagRequired("host")
+
+ rootCmd.PersistentFlags().StringVarP(&mAPI.ProxyURL,
+ "proxy", "", "", "Address of proxy server.")
+}
+
+var rootCmd = &cobra.Command{
+ Use: "dead-tooter",
+ Short: "A CLI for Mastodon hate scripts",
+ Long: `Provides a collection of capabilities that may or may not
+be present in the Mastodon web UI.`,
+
+ PersistentPreRun: func(cmd *cobra.Command, args []string) {
+ token, err := api.LoadToken()
+ if err != nil {
+ log.Fatal("No authentication token found.")
+ }
+ mAPI.Token = token
+ },
+
+ PersistentPostRun: func(cmd *cobra.Command, args []string) {
+ err := mAPI.Token.Save()
+ if err != nil {
+ log.Fatal(err.Error())
+ }
+ },
+}
+
+// Execute base command.
+func Execute() {
+ if err := rootCmd.Execute(); err != nil {
+ log.Fatal(err)
+ }
+}
--- /dev/null
+package tooter
+
+import (
+ "fmt"
+
+ "github.com/spf13/cobra"
+)
+
+func init() {
+ rootCmd.AddCommand(versionCmd)
+}
+
+var versionCmd = &cobra.Command{
+ Use: "version",
+ Short: "Print the version number of d34d-t00ter",
+ Long: "Version, man, version!",
+ Run: func(cmd *cobra.Command, args []string) {
+ fmt.Println("d34d-t00ter, Mastodon hate CLI v0.1")
+ },
+}
+++ /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)
- }
- },
-}
+++ /dev/null
-package tooter
-
-import (
- "errors"
- "log"
-
- "git.vexingworkshop.com/signal9/dead-tooter/pkg/mastodon"
- "github.com/spf13/cobra"
-)
-
-func init() {
- listCmd.AddCommand(listAccountsCmd)
- listCmd.AddCommand(listsContainingCmd)
-
- rootCmd.AddCommand(listCmd)
-}
-
-var listCmd = &cobra.Command{
- Use: "lists",
- Short: "List commands",
- Long: "Commands related to account lists.",
-}
-
-var listAccountsCmd = &cobra.Command{
- Use: "accounts",
- Short: "Get list accounts",
- Long: "Get accounts in a list",
-
- Args: func(cmd *cobra.Command, args []string) error {
- if len(args) < 1 {
- return errors.New("Must provide list id")
- }
- return nil
- },
-
- PreRun: func(cmd *cobra.Command, args []string) {
- err := account.VerifyCredentials(&mAPI)
- if err != nil {
- 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 {
- log.Fatal(err.Error())
- }
-
- accounts, err := list.GetAccounts(&mAPI)
- if err != nil {
- log.Fatal(err.Error())
- }
-
- print(accounts)
- },
-}
-
-var listsContainingCmd = &cobra.Command{
- Use: "containing",
- Short: "Get lists containing [accountid]",
- Long: "Get lists containing a specified account",
-
- PreRun: func(cmd *cobra.Command, args []string) {
- err := account.VerifyCredentials(&mAPI)
- if err != nil {
- log.Fatal(err.Error())
- }
- },
-
- Run: func(cmd *cobra.Command, args []string) {
- var id string
-
- if len(args) < 1 {
- id = account.ID
- } else {
- id = args[0]
- }
-
- lists, err := mastodon.ListsContainingAccount(id, &mAPI)
- if err != nil {
- log.Fatal(err.Error())
- }
-
- lists.Display()
- },
-}
+++ /dev/null
-package tooter
-
-import (
- "log"
-
- "git.vexingworkshop.com/signal9/dead-tooter/pkg/mastodon"
- "github.com/spf13/cobra"
-)
-
-func init() {
- rootCmd.AddCommand(loginCmd)
-}
-
-var loginCmd = &cobra.Command{
- Use: "login",
- Short: "Login to Mastodon",
- Long: "Initiate login to your Mastodon server of choice",
- Run: func(cmd *cobra.Command, args []string) {
- login()
- },
-}
-
-func login() {
- app, err := mastodon.Load("dead-tooter")
- if err != nil {
- client := mastodon.Client{
- ClientName: "dead-tooter",
- RedirectUris: mastodon.RedirectUris,
- Scopes: "read write follow push",
- Website: "https://dead-tooter.vexingworkshop.com",
- }
-
- app, err = mastodon.Create(mAPI.Host, client)
- if err != nil {
- log.Fatalf("Failed to create client: %s\n", err.Error())
- }
-
- err = app.Save()
- if err != nil {
- 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 {
- log.Fatalf("Failed to authorize account: %s\n", err.Error())
- }
-
- mAPI.Token, err = account.RequestToken(mAPI.Host, app, code)
- if err != nil {
- log.Fatalf("Failed to acquire request token: %s\n", err.Error())
- }
-
- err = mAPI.Token.Save()
- if err != nil {
- log.Fatalf("Failed to store access token: %s\n", err.Error())
- }
-
- err = account.VerifyCredentials(&mAPI)
- if err != nil {
- log.Fatalf("Failed to verify credentials: %s\n", err.Error())
- }
-}
+++ /dev/null
-package tooter
-
-import (
- "log"
-
- "git.vexingworkshop.com/signal9/dead-tooter/pkg/mastodon/api"
- "github.com/spf13/cobra"
-)
-
-var mAPI = api.API{}
-
-func init() {
- rootCmd.PersistentFlags().StringVarP(&mAPI.Host,
- "host", "H", "", "Mastodon host where your account lives.")
- rootCmd.MarkPersistentFlagRequired("host")
-
- rootCmd.PersistentFlags().StringVarP(&mAPI.ProxyURL,
- "proxy", "", "", "Address of proxy server.")
-}
-
-var rootCmd = &cobra.Command{
- Use: "dead-tooter",
- Short: "A CLI for Mastodon hate scripts",
- Long: `Provides a collection of capabilities that may or may not
-be present in the Mastodon web UI.`,
-
- PersistentPreRun: func(cmd *cobra.Command, args []string) {
- token, err := api.LoadToken()
- if err != nil {
- log.Fatal("No authentication token found.")
- }
- mAPI.Token = token
- },
-
- PersistentPostRun: func(cmd *cobra.Command, args []string) {
- err := mAPI.Token.Save()
- if err != nil {
- log.Fatal(err.Error())
- }
- },
-}
-
-// Execute base command.
-func Execute() {
- if err := rootCmd.Execute(); err != nil {
- log.Fatal(err)
- }
-}
+++ /dev/null
-package tooter
-
-import (
- "fmt"
-
- "github.com/spf13/cobra"
-)
-
-func init() {
- rootCmd.AddCommand(versionCmd)
-}
-
-var versionCmd = &cobra.Command{
- Use: "version",
- Short: "Print the version number of d34d-t00ter",
- Long: "Version, man, version!",
- Run: func(cmd *cobra.Command, args []string) {
- fmt.Println("d34d-t00ter, Mastodon hate CLI v0.1")
- },
-}
package main
import (
- cmd "git.vexingworkshop.com/signal9/dead-tooter/cmd"
+ cmd "git.vexingworkshop.com/signal9/dead-tooter/cmd/dead-tooter"
)
func main() {