Skip to content

Make --overwrite flag work with ishare2 pull <type> all command #20

Description

@Laminad

When adding the --overwrite flag to the ishare2 pull [type] all command it's not recognizing the flag as part of the command.

I am not entirely sure which function's user input being read from the command line is at fault, but this function seems likely to me. I am only seeing it read one user input regarding type. I also don't see any variables being passed to the function from something that calls this, so it doesn't seem possible for it to handle the --overwrite flag if it were passed to it.

pull_all() {
    TYPE=${1^^}
    if [[ $TYPE == "BIN" ]]; then
        TYPE="IOL"
    fi
    if [[ $TYPE == "QEMU" ]]; then
        echo -e "${YELLOW}[!] WARNING: Pulling all QEMU images will take a long time.\n [!] Make sure you have enough disk space and bandwidth!${NO_COLOR}"
        # Enter confirmation text
        CONFIRMATION="I understand that pulling all QEMU images will take a long time. I have enough disk space and bandwidth."
        # Ask the user to enter the confirmation text
        read -p "[?] Please enter the following text to confirm: \"$CONFIRMATION\" (case sensitive): " -r
        # If the confirmation text is incorrect then exit
        if [[ ! $REPLY =~ ^$CONFIRMATION$ ]]; then
            echo -e "${RED}[!] Aborting.${NO_COLOR}"
            exit 1
        fi
    fi
    echo -e "${YELLOW}[+] Pulling all $TYPE images...${NO_COLOR}"
    # Ask for conirmation
    read -p "[?] Are you sure you want to pull all $TYPE images? (y/n): " -r
    # If reply was no Y or y then exit
    if [[ ! $REPLY =~ ^[Yy]$ ]]; then
        echo -e "${RED}[!] Aborting.${NO_COLOR}"
        exit 1
    fi
    # Get the list of all images
    fetch_json
    # Get all the IDs for the images of the specified type
    IDS=$(jq -r --arg type "$TYPE" '.[$type][] | .id' "$TEMP_JSON")
    # Pull all the images
    i=1
    total=$(echo "$IDS" | wc -l)
    for ID in $IDS; do
        echo -e "${YELLOW}[+] Pulling image $i/$total...${NO_COLOR}"
        ishare2 pull ${TYPE,,} $ID
        i=$((i + 1))
    done
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Fields

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions