updated project 2
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Get the absolute path to the project directory
|
||||
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
CHALLENGE_DIR=~/challenge
|
||||
|
||||
# Colors for output
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
# Function to setup the environment
|
||||
setup_environment() {
|
||||
echo -e "${BLUE}Setting up challenge environment...${NC}"
|
||||
|
||||
# Create directory structure
|
||||
mkdir -p "$CHALLENGE_DIR"/{files,backup,temp}
|
||||
mkdir -p "$CHALLENGE_DIR/.tracking/data"
|
||||
|
||||
# Copy all setup scripts to tracking directory
|
||||
cp "$PROJECT_DIR"/setup/*.sh "$CHALLENGE_DIR/.tracking/"
|
||||
chmod +x "$CHALLENGE_DIR/.tracking/"*.sh
|
||||
|
||||
# Initialize tracking files
|
||||
local data_dir="$CHALLENGE_DIR/.tracking/data"
|
||||
touch "$data_dir"/{progress,score,challenge,commands,time,hints_used,achievements,attempts}.csv
|
||||
|
||||
echo -e "${GREEN}Environment setup complete!${NC}"
|
||||
}
|
||||
|
||||
# Function to start a challenge
|
||||
start_challenge() {
|
||||
local challenge_id=$1
|
||||
|
||||
# Source required scripts
|
||||
source "$CHALLENGE_DIR/.tracking/common.sh"
|
||||
source "$CHALLENGE_DIR/.tracking/challenges.sh"
|
||||
|
||||
clear
|
||||
echo -e "${GREEN}🎮 Command Line Mastery Challenge${NC}"
|
||||
echo "=============================="
|
||||
|
||||
get_challenge_details "$challenge_id"
|
||||
bash "$CHALLENGE_DIR/.tracking/level1-setup.sh"
|
||||
|
||||
local start_time=$(date +%s)
|
||||
echo "$challenge_id,$start_time" > "$CHALLENGE_DIR/.tracking/current_challenge"
|
||||
|
||||
echo -e "\n${GREEN}Challenge ready!${NC}"
|
||||
echo -e "Commands available:"
|
||||
echo -e " ${YELLOW}verify${NC} - Check your solution"
|
||||
echo -e " ${YELLOW}hint${NC} - Get a hint"
|
||||
echo -e " ${YELLOW}status${NC} - Show progress"
|
||||
}
|
||||
|
||||
# Function to show help
|
||||
show_help() {
|
||||
cat << EOF
|
||||
Usage: $0 [command] [options]
|
||||
|
||||
Commands:
|
||||
start <challenge-id> Start a specific challenge
|
||||
list List available challenges
|
||||
setup Setup/reset the environment
|
||||
help Show this help message
|
||||
|
||||
Examples:
|
||||
$0 setup # First time setup
|
||||
$0 list # Show available challenges
|
||||
$0 start 1.1 # Start challenge 1.1
|
||||
EOF
|
||||
}
|
||||
|
||||
# Main execution
|
||||
case "$1" in
|
||||
"setup")
|
||||
setup_environment
|
||||
;;
|
||||
"start")
|
||||
if [[ ! -d "$CHALLENGE_DIR/.tracking" ]]; then
|
||||
echo -e "${YELLOW}Environment not set up. Running setup first...${NC}"
|
||||
setup_environment
|
||||
fi
|
||||
if [[ -z "$2" ]]; then
|
||||
echo "Error: Please specify a challenge ID"
|
||||
echo "Example: $0 start 1.1"
|
||||
exit 1
|
||||
fi
|
||||
start_challenge "$2"
|
||||
;;
|
||||
"list")
|
||||
if [[ -f "$CHALLENGE_DIR/.tracking/challenges.sh" ]]; then
|
||||
source "$CHALLENGE_DIR/.tracking/challenges.sh"
|
||||
list_challenges
|
||||
else
|
||||
echo "Please run setup first: $0 setup"
|
||||
fi
|
||||
;;
|
||||
"help"|"--help"|"-h"|"")
|
||||
show_help
|
||||
;;
|
||||
*)
|
||||
echo "Unknown command: $1"
|
||||
show_help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Base directories
|
||||
CHALLENGE_DIR=~/challenge
|
||||
TRACKING_DIR="$CHALLENGE_DIR/.tracking"
|
||||
DATA_DIR="$TRACKING_DIR/data"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# Create necessary directories
|
||||
mkdir -p "$CHALLENGE_DIR"/{files,backup,temp}
|
||||
mkdir -p "$TRACKING_DIR"
|
||||
mkdir -p "$DATA_DIR"
|
||||
|
||||
# Copy scripts to tracking directory
|
||||
cp "$SCRIPT_DIR/level1-setup.sh" "$TRACKING_DIR/"
|
||||
cp "$SCRIPT_DIR/common.sh" "$TRACKING_DIR/"
|
||||
cp "$SCRIPT_DIR/challenges.sh" "$TRACKING_DIR/"
|
||||
cp "$SCRIPT_DIR/track-progress.sh" "$TRACKING_DIR/"
|
||||
|
||||
# Make scripts executable
|
||||
chmod +x "$TRACKING_DIR"/*.sh
|
||||
|
||||
# Create necessary tracking files
|
||||
touch "$DATA_DIR/progress.csv"
|
||||
touch "$DATA_DIR/score.csv"
|
||||
touch "$DATA_DIR/challenge.log"
|
||||
touch "$DATA_DIR/commands.log"
|
||||
touch "$DATA_DIR/time.log"
|
||||
touch "$DATA_DIR/hints_used.csv"
|
||||
touch "$DATA_DIR/achievements.csv"
|
||||
touch "$DATA_DIR/attempts.csv"
|
||||
|
||||
echo "Environment setup complete!"
|
||||
@@ -1,7 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname "$0")/setup/common.sh"
|
||||
source "$(dirname "$0")/setup/challenges.sh"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
CHALLENGE_DIR=~/challenge
|
||||
|
||||
# Source from tracking directory where scripts are copied
|
||||
source "$CHALLENGE_DIR/.tracking/common.sh"
|
||||
source "$CHALLENGE_DIR/.tracking/challenges.sh"
|
||||
|
||||
# Function to start a challenge
|
||||
start_challenge() {
|
||||
@@ -17,10 +21,11 @@ start_challenge() {
|
||||
|
||||
# Initialize challenge environment
|
||||
echo -e "\n${BLUE}Setting up challenge environment...${NC}"
|
||||
"$CHALLENGE_DIR/.tracking/level1-setup.sh"
|
||||
bash "$CHALLENGE_DIR/.tracking/level1-setup.sh"
|
||||
|
||||
# Record start time
|
||||
local start_time=$(date +%s)
|
||||
mkdir -p "$(dirname "$CHALLENGE_DIR/.tracking/current_challenge")"
|
||||
echo "$challenge_id,$start_time" > "$CHALLENGE_DIR/.tracking/current_challenge"
|
||||
|
||||
echo -e "\n${GREEN}Challenge environment ready!${NC}"
|
||||
|
||||
Reference in New Issue
Block a user