]> Vexing Labs - dead-tooter.git/commitdiff
Move commands to subdir main
authorAdam Shamblin <adam@vexingworkshop.com>
Mon, 16 Jan 2023 18:31:21 +0000 (11:31 -0700)
committerAdam Shamblin <adam@vexingworkshop.com>
Mon, 16 Jan 2023 18:31:21 +0000 (11:31 -0700)
15 files changed:
cmd/account.go [deleted file]
cmd/application.go [deleted file]
cmd/dead-tooter/account.go [new file with mode: 0644]
cmd/dead-tooter/application.go [new file with mode: 0644]
cmd/dead-tooter/doc.go [new file with mode: 0644]
cmd/dead-tooter/list.go [new file with mode: 0644]
cmd/dead-tooter/login.go [new file with mode: 0644]
cmd/dead-tooter/root.go [new file with mode: 0644]
cmd/dead-tooter/version.go [new file with mode: 0644]
cmd/doc.go [deleted file]
cmd/list.go [deleted file]
cmd/login.go [deleted file]
cmd/root.go [deleted file]
cmd/version.go [deleted file]
main.go

diff --git a/cmd/account.go b/cmd/account.go
deleted file mode 100644 (file)
index 70abfa3..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-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()
-       },
-}
diff --git a/cmd/application.go b/cmd/application.go
deleted file mode 100644 (file)
index 31c3d12..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-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) {
-       },
-}
diff --git a/cmd/dead-tooter/account.go b/cmd/dead-tooter/account.go
new file mode 100644 (file)
index 0000000..70abfa3
--- /dev/null
@@ -0,0 +1,155 @@
+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()
+       },
+}
diff --git a/cmd/dead-tooter/application.go b/cmd/dead-tooter/application.go
new file mode 100644 (file)
index 0000000..31c3d12
--- /dev/null
@@ -0,0 +1,15 @@
+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) {
+       },
+}
diff --git a/cmd/dead-tooter/doc.go b/cmd/dead-tooter/doc.go
new file mode 100644 (file)
index 0000000..9de9da5
--- /dev/null
@@ -0,0 +1,34 @@
+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)
+               }
+       },
+}
diff --git a/cmd/dead-tooter/list.go b/cmd/dead-tooter/list.go
new file mode 100644 (file)
index 0000000..a7cab4d
--- /dev/null
@@ -0,0 +1,86 @@
+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()
+       },
+}
diff --git a/cmd/dead-tooter/login.go b/cmd/dead-tooter/login.go
new file mode 100644 (file)
index 0000000..f6dad60
--- /dev/null
@@ -0,0 +1,64 @@
+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())
+       }
+}
diff --git a/cmd/dead-tooter/root.go b/cmd/dead-tooter/root.go
new file mode 100644 (file)
index 0000000..09ea25f
--- /dev/null
@@ -0,0 +1,48 @@
+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)
+       }
+}
diff --git a/cmd/dead-tooter/version.go b/cmd/dead-tooter/version.go
new file mode 100644 (file)
index 0000000..7e0a76e
--- /dev/null
@@ -0,0 +1,20 @@
+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")
+       },
+}
diff --git a/cmd/doc.go b/cmd/doc.go
deleted file mode 100644 (file)
index 9de9da5..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-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)
-               }
-       },
-}
diff --git a/cmd/list.go b/cmd/list.go
deleted file mode 100644 (file)
index a7cab4d..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-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()
-       },
-}
diff --git a/cmd/login.go b/cmd/login.go
deleted file mode 100644 (file)
index f6dad60..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-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())
-       }
-}
diff --git a/cmd/root.go b/cmd/root.go
deleted file mode 100644 (file)
index 09ea25f..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-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)
-       }
-}
diff --git a/cmd/version.go b/cmd/version.go
deleted file mode 100644 (file)
index 7e0a76e..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-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")
-       },
-}
diff --git a/main.go b/main.go
index 8975bc770740c3c6b1c44e640bd4d4ac2c9e56da..c32d14cee5cf9fc82bd7f9d41817de07ea678e52 100644 (file)
--- a/main.go
+++ b/main.go
@@ -1,7 +1,7 @@
 package main
 
 import (
 package main
 
 import (
-       cmd "git.vexingworkshop.com/signal9/dead-tooter/cmd"
+       cmd "git.vexingworkshop.com/signal9/dead-tooter/cmd/dead-tooter"
 )
 
 func main() {
 )
 
 func main() {