11#! /bin/bash
22
3- # Usage: ./diff_command.sh <COMMAND> <USE_MELOS>
3+ # Script: diff_command.sh
4+ # Description: Executes Flutter commands with optional Melos support
5+ # Usage: ./diff_command.sh -n <command> -f <use_melos>
6+ #
7+ # Options:
8+ # -n Flutter command to execute
9+ # -f Use Melos (true/false)
10+ # -p Print debug information
11+ # -h Show this help message
412
513set -e # Exit on any error
614
7- COMMAND=$1
8- USE_MELOS=${2:- false} # Use provided value or default to false if not specified
15+ # Initialize variables with defaults
16+ COMMAND=" "
17+ USE_MELOS=" false"
18+ DEBUG=false
919
20+ # Function to display usage information
21+ show_usage () {
22+ echo " Usage: $0 [-n command] [-f use_melos] [-p] [-h]"
23+ echo " Options:"
24+ echo " -n Flutter command to execute"
25+ echo " -f Use Melos (true/false)"
26+ echo " -p Print debug information"
27+ echo " -h Show this help message"
28+ exit 1
29+ }
30+
31+ # Parse command line options
32+ while getopts " n:f:ph" opt; do
33+ case $opt in
34+ n) COMMAND=" $OPTARG " ;;
35+ f) USE_MELOS=" $OPTARG " ;;
36+ p) DEBUG=true ;;
37+ h) show_usage ;;
38+ ? ) show_usage ;;
39+ esac
40+ done
1041
1142# Validate required parameters
1243if [ -z " $COMMAND " ]; then
13- echo " Error: COMMAND is required"
14- exit 1
44+ echo " Error: Command (-n) is required"
45+ show_usage
1546fi
1647
17- # Validate optional parameters
18-
19- if [ " $USE_MELOS " != true ] && [ " $USE_MELOS " != false ]; then
20- echo " Error: USE_MELOS must be 'true' or 'false'"
21- exit 1
48+ # Validate USE_MELOS parameter
49+ USE_MELOS= $( echo " $USE_MELOS " | tr ' [:upper:] ' ' [:lower:] ' ) # Convert to lowercase
50+ if [ " $USE_MELOS " != " true" ] && [ " $USE_MELOS " != " false" ]; then
51+ echo " Error: Use Melos (-f) must be 'true' or 'false'"
52+ show_usage
2253fi
2354
55+ # Debug output if requested
56+ if [ " $DEBUG " = true ]; then
57+ echo " Configuration:"
58+ echo " - Command: $COMMAND "
59+ echo " - Use Melos: $USE_MELOS "
60+ fi
2461
62+ # Execute command
2563echo " Running command: $COMMAND "
64+ if [ " $USE_MELOS " = " true" ]; then
65+ echo " Using Melos for execution"
66+ # Add Melos-specific command execution here
67+ else
68+ # Add standard command execution here
69+ eval " $COMMAND "
70+ fi
0 commit comments