]> git.frustrated-labs.net Git - squad-rotation-bot.git/commitdiff
feat: add dockerfile for cli tool to manage squad members
authorAlexander Goussas <[email protected]>
Fri, 31 Oct 2025 23:56:44 +0000 (18:56 -0500)
committerAlexander Goussas <[email protected]>
Sun, 2 Nov 2025 00:42:31 +0000 (19:42 -0500)
cli/Dockerfile [new file with mode: 0644]
cli/cli.sh [new file with mode: 0755]
scripts/cli.sh [deleted file]

diff --git a/cli/Dockerfile b/cli/Dockerfile
new file mode 100644 (file)
index 0000000..6266de8
--- /dev/null
@@ -0,0 +1,14 @@
+FROM ubuntu:22.04
+
+WORKDIR /app
+
+RUN apt-get update && apt-get install curl gnupg jq -y
+
+RUN mkdir -p /etc/apt/keyrings && \
+    curl -fsSL https://repo.charm.sh/apt/gpg.key | gpg --dearmor -o /etc/apt/keyrings/charm.gpg && \
+    echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" | tee /etc/apt/sources.list.d/charm.list && \
+    apt update && apt install gum
+
+COPY ./cli.sh /app/cli.sh
+
+CMD /app/cli.sh
diff --git a/cli/cli.sh b/cli/cli.sh
new file mode 100755 (executable)
index 0000000..60bd1c5
--- /dev/null
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+API_BASE='http://localhost:3000'
+
+list_members() {
+  local members=`curl "$API_BASE/api/v1/rotation/members" 2>/dev/null | jq '.[] | .FullName + "," + .AvatarUrl' | tr -d '"'`
+  echo "$members" | gum table --columns="Name,Avatar" --separator="," --print
+}
+
+create_member() {
+  gum style \
+    --foreground "#00e0ee" \
+    --padding '1 1' \
+    --bold \
+    "Add a squad member"
+
+  local full_name=`gum input --placeholder 'Full name' --padding '1 1'` 
+  local avatar_url=`gum input --placeholder 'Avatar URL' --padding '1 1'`
+
+  gum style \
+    --foreground "#00e0ee" \
+    --padding "1 1" \
+    "The squad member '$full_name' is going to be created with avatar: '$avatar_url'"
+
+  if gum confirm 'Proceed with creation?'; then
+    local result=`curl -X POST -i -s "$API_BASE/api/v1/rotation/members" -d "{ \"FullName\": \"$full_name\", \"AvatarUrl\": \"$avatar_url\" }"`
+    local status_code=`echo $result | head -n1 | cut -d' ' -f2`
+    if [ "$status_code" = '201' ]; then
+      gum style --foreground "#00ff00" --bold --padding "1 1" "User created successfully"
+    else
+      gum style --foreground "#ff0000" --bold --padding "1 1" "There was an error creating the user"
+    fi
+  else
+    gum style --foreground "#ff0000" --bold --padding "1 1" 'Operation aborted'
+  fi
+}
+
+read -r -d '' menu_options <<'EOF'
+1. List squad members
+2. Add squad member
+3. Exit
+EOF
+
+while :; do
+  choice=`echo "$menu_options" | gum choose --header "Menu Options" --padding "1 1" --header.bold | cut -d'.' -f1`
+  case $choice in
+    1)
+      list_members
+      ;;
+    2)
+      create_member
+      ;;
+    3)
+      exit 0
+      ;;
+  esac
+done
diff --git a/scripts/cli.sh b/scripts/cli.sh
deleted file mode 100755 (executable)
index 60bd1c5..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/bin/bash
-
-API_BASE='http://localhost:3000'
-
-list_members() {
-  local members=`curl "$API_BASE/api/v1/rotation/members" 2>/dev/null | jq '.[] | .FullName + "," + .AvatarUrl' | tr -d '"'`
-  echo "$members" | gum table --columns="Name,Avatar" --separator="," --print
-}
-
-create_member() {
-  gum style \
-    --foreground "#00e0ee" \
-    --padding '1 1' \
-    --bold \
-    "Add a squad member"
-
-  local full_name=`gum input --placeholder 'Full name' --padding '1 1'` 
-  local avatar_url=`gum input --placeholder 'Avatar URL' --padding '1 1'`
-
-  gum style \
-    --foreground "#00e0ee" \
-    --padding "1 1" \
-    "The squad member '$full_name' is going to be created with avatar: '$avatar_url'"
-
-  if gum confirm 'Proceed with creation?'; then
-    local result=`curl -X POST -i -s "$API_BASE/api/v1/rotation/members" -d "{ \"FullName\": \"$full_name\", \"AvatarUrl\": \"$avatar_url\" }"`
-    local status_code=`echo $result | head -n1 | cut -d' ' -f2`
-    if [ "$status_code" = '201' ]; then
-      gum style --foreground "#00ff00" --bold --padding "1 1" "User created successfully"
-    else
-      gum style --foreground "#ff0000" --bold --padding "1 1" "There was an error creating the user"
-    fi
-  else
-    gum style --foreground "#ff0000" --bold --padding "1 1" 'Operation aborted'
-  fi
-}
-
-read -r -d '' menu_options <<'EOF'
-1. List squad members
-2. Add squad member
-3. Exit
-EOF
-
-while :; do
-  choice=`echo "$menu_options" | gum choose --header "Menu Options" --padding "1 1" --header.bold | cut -d'.' -f1`
-  case $choice in
-    1)
-      list_members
-      ;;
-    2)
-      create_member
-      ;;
-    3)
-      exit 0
-      ;;
-  esac
-done