feat(muse-cli): streamlined account argument handling and extracted clean inner invocation wrapper

This commit is contained in:
operator
2026-10-05 16:02:46 +00:00
parent a0297b733a
commit e912f25dd7
3 changed files with 35 additions and 18 deletions
+14 -6
View File
@@ -14,11 +14,8 @@ NETVM_BIN="$(cd -P "$(dirname "$SCRIPT_SRC")" && pwd)"
VALID_ACCOUNTS=("muse" "pip" "646" "opm" "def" "dev")
show_usage() {
echo "Usage: muse --account <name> <command> [arguments...]"
echo " muse -a <name> <command> [arguments...]"
echo ""
echo "Required:"
echo " -a, --account <name> Target NetVM account / node identity"
echo "Usage: muse <account> <command> [arguments...]"
echo " muse -a <account> <command> [arguments...]"
echo ""
echo "Available accounts:"
for acct in "${VALID_ACCOUNTS[@]}"; do
@@ -42,6 +39,17 @@ show_usage() {
ACCOUNT=""
POSITIONAL=()
# Pre-check if first argument is a valid account name (e.g. 'muse 646 ...')
if [[ $# -gt 0 ]]; then
for acct in "${VALID_ACCOUNTS[@]}"; do
if [[ "$1" == "$acct" ]]; then
ACCOUNT="$1"
shift
break
fi
done
fi
while [[ $# -gt 0 ]]; do
case "$1" in
-a|--account)
@@ -72,7 +80,7 @@ while [[ $# -gt 0 ]]; do
done
if [[ -z "$ACCOUNT" ]]; then
echo "Error: No account specified. Please specify an account with -a or --account." >&2
echo "Error: No account specified. Specify account as first argument or with -a/--account." >&2
echo ""
show_usage
exit 1