Skip to content

Commit

Permalink
feat: transferred ownership
Browse files Browse the repository at this point in the history
  • Loading branch information
WajahatAliAbid committed Oct 15, 2024
1 parent d77ddca commit b23438b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 26 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Zqs makes it easier to send messages to the Amazon SQS. Just provide it file or
Install zqs using go cli

```bash
go install github.com/ZenExtensions/zqs
go install github.com/WajahatAliAbid/zqs
```

## Features
Expand All @@ -36,7 +36,7 @@ zqs send-message my-queue -d "./dir-of-files`"
Clone the project
```bash
git clone https://github.com/github.com/ZenExtensions/zqs
git clone https://github.com/github.com/WajahatAliAbid/zqs
```
Go to the project directory
Expand Down
43 changes: 21 additions & 22 deletions cmd/sendMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ package cmd
import (
"bufio"
"encoding/json"
"fmt"
"io"
"io/fs"
"net/url"
"os"
"path/filepath"
"time"

"github.com/ZenExtensions/zqs/helper"
"github.com/WajahattAliAbid/zqs/helper"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/pterm/pterm"
Expand Down Expand Up @@ -168,8 +166,6 @@ func RunSendMessages(cmd *cobra.Command, args []string) {
jsons = append(jsons, *infos...)
}
}
logger.Printfln("length: %d", len(jsons))

client := helper.New(&config)
queueName := args[0]
queueUrlParsed, err := url.ParseRequestURI(queueName)
Expand All @@ -186,17 +182,22 @@ func RunSendMessages(cmd *cobra.Command, args []string) {
queueUrl = queueUrlParsed.String()
}

logger.Printfln(queueUrl)
spinner := pterm.DefaultSpinner
spinner.Sequence = []string{
"🙈",
"🙉",
"🙊",
progress_bar, err := pterm.DefaultProgressbar.
WithTitle("Sending messages").
WithTotal(len(jsons)).
WithCurrent(0).
WithShowElapsedTime(true).
WithShowCount(true).
WithRemoveWhenDone(false).
WithBarCharacter(pterm.DefaultBarChart.HorizontalBarCharacter).
WithShowPercentage(true).
WithShowTitle(true).
Start()
if err != nil {
logger.Printfln(pterm.Red(err.Error()))
os.Exit(1)
}
spinner.Delay = 300 * time.Millisecond
spinnerPrinter, _ := spinner.Start("Sending messages")
chunks := chunkBy(jsons, 10)

for _, chunk := range chunks {

err := client.SendMessages(
Expand All @@ -205,18 +206,16 @@ func RunSendMessages(cmd *cobra.Command, args []string) {
&chunk,
)

spinnerPrinter.UpdateText(
fmt.Sprintf(
"Sent %d of %d messages",
len(chunk),
len(jsons),
),
)

if err != nil {
logger.Printfln(pterm.Red(err.Error()))
os.Exit(1)
}

for i := 0; i < len(chunk); i++ {
progress_bar.Increment()
}
}

logger.Printfln(pterm.Green("Messages sent successfully"))

}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/ZenExtensions/zqs
module github.com/WajahattAliAbid/zqs

go 1.22.0

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Copyright © 2024 WajahatAliAbid
*/
package main

import cmd "github.com/ZenExtensions/zqs/cmd"
import cmd "github.com/WajahattAliAbid/zqs/cmd"

func main() {
cmd.Execute()
Expand Down

0 comments on commit b23438b

Please sign in to comment.