use ego-mgr for username/email instead of CLI flags

This commit is contained in:
lyn
2026-03-24 19:18:20 +00:00
parent 2d37e9d55f
commit b9785b6295
5 changed files with 48 additions and 69 deletions

View File

@@ -3,27 +3,19 @@
# Get the directory where this script is located # Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# Parse arguments # Get username and email from ego-mgr
while [[ $# -gt 0 ]]; do username=$(ego-mgr get default-username)
case $1 in email=$(ego-mgr get email)
--username)
username="$2"
shift 2
;;
--email)
email="$2"
shift 2
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
# Check if username and email are provided # Check if username is provided
if [[ -z "$username" || -z "$email" ]]; then if [[ -z "$username" ]]; then
echo "Usage: $0 --username <username> --email <email>" echo "Error: default-username not set in ego-mgr, please contact ard"
exit 1
fi
# Check if email is provided
if [[ -z "$email" ]]; then
echo "Error: email not set in ego-mgr, please contact ard"
exit 1 exit 1
fi fi

View File

@@ -3,6 +3,15 @@
# Get the directory where this script is located # Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# Get username from ego-mgr
username=$(ego-mgr get default-username)
# Check if username is provided
if [[ -z "$username" ]]; then
echo "Error: default-username not set in ego-mgr, please contact ard"
exit 1
fi
roster=false roster=false
# Parse arguments # Parse arguments

View File

@@ -2,15 +2,13 @@
set -euo pipefail set -euo pipefail
usage() { usage() {
echo "Usage: $0 --repo-path <path> --email <email> [--recursive]" echo "Usage: $0 --repo-path <path> [--recursive]"
echo " --repo-path: Path to the git repository" echo " --repo-path: Path to the git repository"
echo " --email: Email address to configure"
echo " --recursive: Also configure all submodules (recursive)" echo " --recursive: Also configure all submodules (recursive)"
exit 2 exit 2
} }
REPO_PATH="" REPO_PATH=""
EMAIL=""
RECURSIVE=false RECURSIVE=false
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
@@ -19,10 +17,6 @@ while [[ $# -gt 0 ]]; do
REPO_PATH="${2:-}" REPO_PATH="${2:-}"
shift 2 shift 2
;; ;;
--email)
EMAIL="${2:-}"
shift 2
;;
--recursive) --recursive)
RECURSIVE=true RECURSIVE=true
shift shift
@@ -33,10 +27,19 @@ while [[ $# -gt 0 ]]; do
esac esac
done done
if [[ -z "$REPO_PATH" || -z "$EMAIL" ]]; then if [[ -z "$REPO_PATH" ]]; then
usage usage
fi fi
# Get email from ego-mgr
EMAIL=$(ego-mgr get email)
# Check if email is provided
if [[ -z "$EMAIL" ]]; then
echo "Error: email not set in ego-mgr, please contact ard"
exit 1
fi
# Check if it's a git repo (either .git is a directory or a file with gitdir: reference) # Check if it's a git repo (either .git is a directory or a file with gitdir: reference)
is_git_repo() { is_git_repo() {
local repo="$1" local repo="$1"

View File

@@ -3,27 +3,19 @@
# Get the directory where this script is located # Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# Parse arguments # Get username and email from ego-mgr
while [[ $# -gt 0 ]]; do username=$(ego-mgr get default-username)
case $1 in email=$(ego-mgr get email)
--username)
username="$2"
shift 2
;;
--email)
email="$2"
shift 2
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
# Check if username and email are provided # Check if username is provided
if [[ -z "$username" || -z "$email" ]]; then if [[ -z "$username" ]]; then
echo "Usage: $0 --username <username> --email <email>" echo "Error: default-username not set in ego-mgr, please contact ard"
exit 1
fi
# Check if email is provided
if [[ -z "$email" ]]; then
echo "Error: email not set in ego-mgr, please contact ard"
exit 1 exit 1
fi fi

View File

@@ -3,29 +3,12 @@
# Get the directory where this script is located # Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# Optional explicit username # Get username from ego-mgr
username="" username=$(ego-mgr get default-username)
while [[ $# -gt 0 ]]; do
case $1 in
--username)
username="$2"
shift 2
;;
*)
echo "Unknown option: $1"
echo "Usage: $0 [--username <username>]"
exit 1
;;
esac
done
# Default to secret-mgr if not provided # Check if username is provided
if [[ -z "$username" ]]; then if [[ -z "$username" ]]; then
username=$(secret-mgr get-username --key keycloak) echo "Error: default-username not set in ego-mgr, please contact ard"
fi
if [[ -z "$username" ]]; then
echo "Error: No keycloak username found in secret-mgr"
exit 1 exit 1
fi fi