Skip to content

Commit

Permalink
Refactor script to organize commands into functions
Browse files Browse the repository at this point in the history
- Created a new function: 'auth'
- 'auth' is dedicated to the 'login' command
- Modified 'rootUsage' to direct to these new functions based on user input
- Updated help message to reflect the new command structure
  • Loading branch information
hiroTochigi committed Jan 6, 2024
1 parent 920e3aa commit 6c7bd6b
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 13 deletions.
File renamed without changes.
26 changes: 26 additions & 0 deletions src/azure/auth/driver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
authUsage() {
echo "Usage: $0 credential [command]"
echo "Commands:"
echo " login - Login azure as service-principal"
exit 1
}

function auth(){

# Check if at least one argument is provided
if [ $# -eq 0 ]; then
authUsage
fi

# Execute the appropriate command
case "$1" in
login)
login
;;
*)
echo "Error: Invalid command."
authUsage
;;
esac

}
2 changes: 2 additions & 0 deletions src/azure/auth/loadScripts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
source auth/Login.sh
source auth/driver.sh
File renamed without changes.
2 changes: 1 addition & 1 deletion src/azure/credential/loadScripts.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source credential/credentialDriver.sh
source credential/driver.sh
source credential/SetupCred.sh
source credential/ShowCreds.sh
source credential/UpdateCreds.sh
Expand Down
20 changes: 9 additions & 11 deletions src/azure/driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,29 @@
source config.sh
source loadScripts.sh

usage() {
echo "Usage: $0 [command]"
echo "Commands:"
echo " init - Initialize and store new credentials"
echo " update - Update existing credentials"
echo " show - Display current credentials"
echo " login - Login azure as service-principal"
rootUsage() {
echo "Usage: $0 [command group] [command]"
echo "Command groups:"
echo " credential - Manage credentials (init, update, show)"
echo " auth - Authentication management (login)"
exit 1
}

# Check if at least one argument is provided
if [ $# -eq 0 ]; then
usage
rootUsage
fi

# Execute the appropriate command
case "$1" in
credential)
credential "$2"
;;
login)
login
auth)
auth "$2"
;;
*)
echo "Error: Invalid command."
usage
rootUsage
;;
esac
2 changes: 1 addition & 1 deletion src/azure/loadScripts.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source credential/loadScripts.sh
source auth/loadScripts.sh

source Login.sh

0 comments on commit 6c7bd6b

Please sign in to comment.