Stepper motor button control

I am controlling a nema17 stepper motor with a drv8825 driver. I would like to be able to use 2 push buttons and 2 limit switches to control it. A click of button 1 should enable the motor and make it rotate clockwise until limit 1 is pressed. When limit 1 is pressed it should stop and disable the motor. Button 2 and switch 2 should do the same thing but counter clockwise.

I have the buttons and switches connected between 5v and a digital pin each.

Any pointers would be greatly appreciated. This is my first time using c++ or an arduino so apologies if i miss something out or am just generally stupid. My setup code is below:

#include <AccelStepper.h>

// Define pin numbers for stepper motor control
#define dirPin 2
#define stepPin 3
#define enPin 10
#define fltPin 11

// Define pin numbers for buttons
#define closePin 22
#define openPin 23
#define cstopPin 24
#define ostopPin 25

// Create an instance of the AccelStepper class
AccelStepper stepper(AccelStepper::DRIVER, stepPin, dirPin);

void setup() {
  // Begin serial communication
  Serial.begin(9600);

  // Set up pins for stepper motor control
  pinMode(enPin, OUTPUT);
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
  pinMode(fltPin, INPUT_PULLUP);

  // Set up pins for buttons
  pinMode (closePin, INPUT);
  pinMode (openPin, INPUT);
  pinMode (cstopPin, INPUT);
  pinMode (ostopPin, INPUT);

  // Disable the stepper motor driver initially
  digitalWrite(enPin, HIGH);

  // Set stepper motor parameters
  stepper.setMaxSpeed(1000.0);
  stepper.setAcceleration(500.0);
}

It's easier to put the buttons and switches between the digital pin and ground so the read LOW when pressed. Then you can use INPUT_PULLUP in pinMode and they won't float when the button isn't pressed. Otherwise, the way you have them now, you'd need to add a pull-down resistor to the circuit to hold the pin LOW when the button isn't pressed.

in order to stop immediately when the limit switch is hit, the motor needs to be stepped one step at a time with a check of the limit switches in between each step

For the logic of limit switch and stepper motor, you can refer to this Arduino limit switch and stepper motor tutorial