diff options
Diffstat (limited to 'cmd/x.go')
| -rw-r--r-- | cmd/x.go | 54 |
1 files changed, 53 insertions, 1 deletions
@@ -32,10 +32,28 @@ var xTweetsCmd = &cobra.Command{ RunE: runXTweetsSearch, } +var xFirstCmd = &cobra.Command{ + Use: "first [username]", + Short: "Get first 20 followers of a Twitter/X account", + Long: `Retrieves the first 20 followers of a Twitter/X account`, + Args: cobra.ExactArgs(1), + RunE: runXFirstFollowers, +} + +var xNFLCmd = &cobra.Command{ + Use: "nfl [username]", + Short: "Get notable followers of a Twitter/X account", + Long: `Retrieves the notable followers (influential accounts) following a Twitter/X account`, + Args: cobra.ExactArgs(1), + RunE: runXNotableFollowers, +} + func init() { rootCmd.AddCommand(xCmd) xCmd.AddCommand(xHistoryCmd) xCmd.AddCommand(xTweetsCmd) + xCmd.AddCommand(xFirstCmd) + xCmd.AddCommand(xNFLCmd) } func runXHistorySearch(cmd *cobra.Command, args []string) error { @@ -72,7 +90,7 @@ func runXHistorySearch(cmd *cobra.Command, args []string) error { func runXTweetsSearch(cmd *cobra.Command, args []string) error { cfg := config.New() - c, err := client.New(cfg) + c, err := client.NewUnauthenticated(cfg) if err != nil { return err } @@ -88,3 +106,37 @@ func runXTweetsSearch(cmd *cobra.Command, args []string) error { return nil } + +func runXFirstFollowers(cmd *cobra.Command, args []string) error { + apiKey, _ := cmd.Flags().GetString("api-key") + cfg := config.New().WithAPIKey(apiKey) + + c, err := client.New(cfg) + if err != nil { + return err + } + + response, err := c.GetFirstFollowers(args[0]) + if err != nil { + return err + } + + return utils.PrintJSON(response) +} + +func runXNotableFollowers(cmd *cobra.Command, args []string) error { + apiKey, _ := cmd.Flags().GetString("api-key") + cfg := config.New().WithAPIKey(apiKey) + + c, err := client.New(cfg) + if err != nil { + return err + } + + response, err := c.GetNotableFollowers(args[0]) + if err != nil { + return err + } + + return utils.PrintJSON(response) +} |
